Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Location
    Ohio
    Posts
    286
    Thanks
    7
    Thanked 9 Times in 9 Posts

    JS attribute "onload" failing validation

    While validating my homepage, only one error came up, that being an issue with a javascript I am using for a clickable rotating banner.

    This is what the validation page is saying:
    Error Line 147 column 13: there is no attribute "onLoad".

    <body onLoad="window.setTimeout('cycle();',3000);(loadbanners());(urlswitch())..
    However, I do not understand what is wrong because the script would not work if the attribute were not somewhere in the body, correct?

    I am using <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    for a doctype and I am not sure if the problem lies with using an incorrect doctype or not.

    Here is the script I am using:
    Code:
    <script language="JavaScript1.1" type="text/javascript">
    <!--
    /* Banner Up! - Copyright 1999-2000 By Heidi Allen 
    Knowledge Hound: The How-To Hunter - Learn how to do almost anything...for free!
    Please visit us at http://www.knowledgehound.com
    License for use of this script is granted if and only if
    this entire copyright notice is included with it. We do not provide
    support for this script. It is provided solely as a friendly gesture.
    Use at your own risk. Thanks! */
    // Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/
    var image="";
    var banners=0;
    function cycle() {
      if (++banners > 7) banners=1;
        loadbanners();
        document.banner1.src = image;
        window.setTimeout('cycle();',3000);
      }
    function loadbanners() {
       if (banners==1)
          {
          image="images/dcombanner.png";
          }
       if (banners==2)
          {
          image="images/harryp.png";
          }
       if (banners==3)
          {
          image="images/disclaimer.jpg";
          }
       if (banners==4)
          {
          image="images/junk.jpg";
          }
       if (banners==5)
          {
          image="images/midcalbanner.png";
          }
       if (banners==6)
          {
          image="images/xfiles.gif";
          }
       if (banners==7)
          {
          image="images/entertainment.gif";
          }
    }
    //-->
    </script>
    
    <script language="JavaScript1.1" type="text/javascript">
    <!--
    var link = "index.html"
    function urlswitch() {
    if (banners==1)
    {
    link = "index.html";
    }
    if (banners==2)
    {
    link = "potterealm/potterealm.html";
    }
    if (banners==3)
    {
    link = "claim.html";
    }
    if (banners==4)
    {
    link = "junk/junk.html";
    }
    if (banners==5)
    {
    link = "midnightcalvin/midnightcalvin.html";
    }
    if (banners==6)
    {
    link = "thelambs/xf/xfiles.html";
    }
    if (banners==7)
    {
    link = "thelambs/thelambs.html";
    }
    return link;
    }
    //-->
    </script>
    And this is the HTML:
    Code:
    <body onLoad="window.setTimeout('cycle();',3000);(loadbanners());(urlswitch());">
    
    (body content erroneous to the script)
    
    <p><a href="index.html" onclick="this.href=urlswitch()">
    <img width="468" height="60" border="0" src="images/dcombanner.png" name="banner1" alt="banner" /></a></p>
    If anyone knows what may be wrong with either the script or the doctype I am using, I would be most grateful for his or her help.

    Many thanks!

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Try using onload.


  •  

    Posting Permissions

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