Terms of Use Javascript

Need: A script that a client could easily call within a URL to force the users to agree to their terms of use before downloading a file.

Solution:Either put the following code in the header, or in a .js file to include:

JAVASCRIPT:
  1. <script type="text/javascript">
  2. function terms(){
  3.     question = confirm("Terms of Use text here")
  4.  if (question !="0"){
  5.         document.URL()
  6.     }
  7.   }
  8. </script>

Then, call this code in your HTML code by using:

HTML:
  1. <a href="http://www.sandboxdev.com" onclick="terms();return false;" value="Display Terms of Use" />Download Link</a>

2 Responses to “Terms of Use Javascript”

  1. Doug Blatti says:

    Good job – I’m sure this one will come in handy in the future.

  2. jzelazny says:

    I am surprised there are not more articles available on this – but I am always happy to share.

Leave a Reply