www.webdeveloper.com
Results 1 to 2 of 2

Thread: Class for external links - warning alert

  1. #1
    Join Date
    Dec 2011
    Posts
    22

    Class for external links - warning alert

    Hi,
    in order to open a warning pop up when leaving page
    I have this script:

    function Warning() {
    window.confirm
    var answer = confirm("Wanna leave page?");

    if (answer == true)
    {
    window.location= href;
    }
    else
    {
    return false;
    }
    }

    I would like to call a function, with a specific class for all the external links.

    function externalLinks() {
    var anchors = document.getElementsByTagName('a');
    for(var i=0; i<anchors.length;i++) {
    if(anchors[i].className) {
    if(anchors[i].href && anchors[i].className == "LinkedList") {
    anchors[i].target = "_blank"; ;
    }
    }
    }
    }


    How is it possible to get the class and open the popup?

    (and yes I know that a warning popup is annoying... Im told to do this)

  2. #2
    Join Date
    Dec 2011
    Posts
    22
    What is the syntax for classname?

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