Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthornxtyear
    • CommentTimeJul 24th 2006
     permalink
    is there some sort of a mismatch using the two?

    I have a header include which i use for all the pages in my site.
    inside the header (and inside the <head> tag), included a javascript:

    <script src="http://www.mysitecom/externallink.js" type="text/javascript"></script>

    ok what does externallink.js do? it's a script i picked up from boagworld, anyways it looks for all <a> tags with class="externalLink" , and chnges the clss of those to newWinStyle, and it also opens the link in a new window:

    ------------------------------------------
    function doPopups() {
    if (!document.getElementsByTagName) return false;
    var links = document.getElementsByTagName("a");
    for (var i=0; i < links.length; i++) {
    if (links[i].className.match("externalLink")) {
    links[i].className = links[i].className + " newWinStyle";
    links[i].title = links[i].title + " (new window)";
    links[i].onclick = function() {
    window.open(this.href);
    return false;
    }
    }
    }
    }

    ------------------------------
    anyways, i'm just wondering why it isn't working!!!

    is there some problems when i included an external js into a php include which in turn is included into all my pages??
    (ok that sounded confusing but u get what i mean)
  1.  permalink
    Worked like a charm. I'd imagine that the php include is included somewhere within the head-tag, right?

    <head>
    <title>X</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <style>
    .newWinStyle {font: normal 2em verdana;}
    </style>
    <script type="text/javascript">
    function doPopups() {
    if (!document.getElementsByTagName) return false;
    var links = document.getElementsByTagName("a");
    for (var i=0; i < links.length; i++) {
    if (links[i].className.match("externalLink")) {
    links[i].className = links[i].className + " newWinStyle";
    links[i].title = links[i].title + " (new window)";
    links[i].onclick = function() {
    window.open(this.href);
    return false;
    }
    }
    }
    }
    </script>
    </head>
    <body onload="doPopups();">
    <a href="#" class="externalLink">test</a>
    <a href="#" class="externalLink">test2</a>
    <a href="#" class="externalLink">test3</a>
    </body>

    There shouldn't be any difference between the sample code above and using external .js or php includes, as long as they are included in appropriate places.
    • CommentAuthornxtyear
    • CommentTimeJul 25th 2006
     permalink
    hmmm weird, i later on thought the problem was due to the fact that getElementsByTagName wasn't supported by Javascript.... guess that's not the reason :S
Add your comments
    Username Password
  • Format comments as (Help)