Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

including a file stops function from runing?? why

  • 09-07-2008 12:03AM
    #1
    Registered Users, Registered Users 2 Posts: 483 ✭✭


    lo,
    csn any one see why including this function on to a web page:
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    startList = function() {
        if (document.all&&document.getElementById) {
            navRoot = document.getElementById("nav");
            for (i=0; i<navRoot.childNodes.length; i++) {
                node = navRoot.childNodes[i];
                if (node.nodeName=="LI") {
                    node.onmouseover=function() {
                        this.className+=" over";
                    }
                    node.onmouseout=function() {
                        this.className=this.className.replace(" over", "");
                    }
                }
            }
        }
    }
    window.onload=startList;
    //--><!]]>
    </script>
    
    would stop this function running on the
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAsiQvuugI6Ni06Zq-4qcw8xRDySWSj47LhKkbc2n0qzQPgi3L7hS02DtDqb_nguwz4fdmwsrHj5E1vw"type="text/javascript"></script>
    <script type="text/javascript">
    function load() {
        if (GBrowserIsCompatible()) {
           var map = new GMap2(document.getElementById("map"));
           map.addControl(new GSmallMapControl());
           map.addControl(new GMapTypeControl());
           map.setCenter(new GLatLng(53.396432, -7.470703), 5);      
           GEvent.addListener(map, "click", function(overlay, point){
             map.clearOverlays();
             if (point) {
                 map.addOverlay(new GMarker(point));
                 map.panTo(point);
                 document.form1.mylat.value = point.lat();
                 document.form1.mylng.value = point.lng();
        
             }  //close if(point)...
           });   //close GEvent...
        }  //close if(GBrowser...
    } //close load()
    </script>
    
    ive been lookin for ages and my brain is fried!!

    Cheers
    Richie


Comments

  • Closed Accounts Posts: 81 ✭✭dzy


    Your best bet would be to install the Firebug extension for Firefox and step through the code in that.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    ^^ what dzy said++


  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Another +1.

    This is completely off the top of my head, but you are using:
    window.onload=startList;
    

    Is there any chance that this is overriding an onload event elsewhere?

    I think it's better practise to use:
    window.attachEvent("onload", functionname);
    


  • Registered Users, Registered Users 2 Posts: 483 ✭✭banbutcher


    eoin_s wrote: »
    Another +1.

    This is completely off the top of my head, but you are using:
    window.onload=startList;
    
    Is there any chance that this is overriding an onload event elsewhere?

    I think it's better practise to use:
    window.attachEvent("onload", functionname);
    


    Yep thats done it! i had a feeling that that might have had something to do with it alright! thanks eoin!!


  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    banbutcher wrote: »
    Yep thats done it! i had a feeling that that might have had something to do with it alright! thanks eoin!!

    Wow - that was complete guesswork on my side!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 483 ✭✭banbutcher


    good guess work tho!! :P


Advertisement