www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] Disclaimer Page

  1. #1
    Join Date
    May 2010
    Posts
    8

    resolved [RESOLVED] Disclaimer Page

    I am needing to create a script that will open a disclaimer page anytime a person clicks on an external link.

    I work for a school district and it is the district policy that links leading away from the school sites must be identified. However our teachers will not do this on their own.

    What I would like to do is to setup a cookie that will capture what the destination address is so when an external link is selected it will save the destination address and apply it to the continue link on the disclaimer page.

    An example of what I'm needing is at: http://apps.irs.gov/app/freeFile/jsp/index.jsp?ck

    That's exactly what I'm needing. I know that doing something like this is an annoyance to users, but considering that I have 1000 users creating web pages that think Word is a web development program I need to automate this.

    I can get a system message to appear by using onclick, but that requires the users to place that on the link each time. I've also got the following script:

    function winClose()
    {
    if (confirm("Message here"))
    {
    window.close();
    }

    return false;
    }

    <body onUnload="return winClose();; return false;">

    This opens the message, but clicking on the cancel button still takes me to the external page plus it opens on every link, not just external ones.

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    <script type="text/javascript">
    window.onload=function() {
    var myDomain = 'mydomain.com'; // change this
    var aObj=document.getElementsByTagName('a');
    var i=aObj.length; 
    while(i--) { 
        if(aObj[i].href.indexOf(myDomain)!=-1) {
            aObj[i].onclick = function() {return winClose();};
            }
        }
    };
    
    function winClose() {
    if (confirm("Message here")) {
        return true;
        }
    return false;
    }
    </script>

  3. #3
    Join Date
    May 2010
    Posts
    8
    This function doesn't work. It just takes me directly to the external site. No message or anything. I tried it a few different ways. On the page, external file, typing myDomain with the protocol and without. I also tried adding an onUnload to the body tag.

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    if(aObj[i].href.indexOf(myDomain)==-1) {

  5. #5
    Join Date
    May 2010
    Posts
    8
    That worked. Thanks so much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles