help me to remove startup error of my blog?

Discussion in 'JavaScript' started by aliqayyum, Oct 27, 2009.

  1. #1
    hi
    respected friends
    i have problem, while loading of page in Internet Explorer
    i have software related website http://alisoft7.blogspot.com
    when i opened page. i have seen this error on status bar.

    i attached the picture
    [​IMG]

    kindly see this error and help me
    thanks in advance
     
    aliqayyum, Oct 27, 2009 IP
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    I didn't get that error in IE, and firefox i only had one that related to google i think...
    But wow that is a lot of code for one page.
     
    camjohnson95, Oct 27, 2009 IP
  3. tag44

    tag44 Peon

    Messages:
    272
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The error shows on Line 1517 under chart 15 that your site sfEls1 is undefined.
    So kindly check that code properly and solve the error.
     
    tag44, Oct 27, 2009 IP
  4. aliqayyum

    aliqayyum Peon

    Messages:
    329
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for your reply
    this is the code
    can u remove this error? because i hate javascript . so i could not do my self


    <script type='text/javascript'><!--//--><![CDATA[//><!--
    sfHover = function() {
    var sfEls = document.getElementById("menu").getElementsByTagName("LI");

    for (var i=0; i<sfEls.length; i++) {
    sfEls.onmouseover=function() {
    this.className+=" sfhover";
    }
    sfEls.onmouseout=function() {
    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
    }
    }
    for (var i=0; i<sfEls1.length; i++) {
    sfEls1.onmouseover=function() {
    this.className+=" sfhover1";
    }
    sfEls1.onmouseout=function() {
    this.className=this.className.replace(new RegExp(" sfhover1\\b"), "");
    }
    }

    }
    if (window.attachEvent) window.attachEvent("onload", sfHover);
    //--><!]]></script>
     
    aliqayyum, Oct 27, 2009 IP
  5. aliqayyum

    aliqayyum Peon

    Messages:
    329
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    there is an error on IE. see the status bar
    i placed the code. see
     
    aliqayyum, Oct 27, 2009 IP
  6. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #6
    You define sfEls:
    
    var sfEls = document.getElementById("menu").getElementsByTagName("LI");
    
    Code (markup):
    but not sfEls1 which is used here:
    
    for (var i=0; i<sfEls1.length; i++) {
    sfEls1[i].onmouseover=function() {
    this.className+=" sfhover1";
    }
    sfEls1[i].onmouseout=function() {
    this.className=this.className.replace(new RegExp(" sfhover1\\b"), "");
    }
    }
    
    Code (markup):
    but not defined. So you need to either define it to the element that it is supposed to be, or remove the above code.
     
    camjohnson95, Oct 27, 2009 IP
  7. aliqayyum

    aliqayyum Peon

    Messages:
    329
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thanks for the help i removed the code... and now error found, i think, this code doesn't help me in the website
    thanks
     
    aliqayyum, Oct 27, 2009 IP
  8. zeeside

    zeeside Greenhorn

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #8
    you could do a null check first before you try a "getElementsByTagName" call.

    eg.

    var sfEls ;

    if (document.getElementById("menu"))
    {
    sfEls = document.getElementById("menu").getElementsByTagName("LI");
    }

    It's always good practice to do a null check before calling functions on an object.
     
    zeeside, Nov 3, 2009 IP
  9. aliqayyum

    aliqayyum Peon

    Messages:
    329
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    i removed the errors
    thanks you all guys
     
    aliqayyum, Nov 3, 2009 IP