...

View Full Version : JS attribute "onload" failing validation



kaitco
01-24-2006, 09:48 AM
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:

<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:

<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!

glenngv
01-24-2006, 10:25 AM
Try using onload.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum