Forum Moderators: open

Message Too Old, No Replies

onload Won't Validate

         

gldweb

12:28 am on Jul 24, 2005 (gmt 0)

10+ Year Member



Hi there - I am using the onload attribite to swap an image but when I try an validate my code it tells me that - there is no attribute "onload". I have changed it to lower case and still the same message. Any help would be greatly appreciated.

Here is the DOCTYPE I am using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

Here is the code where I am using onload:

<img src="images/japan_map.jpg" alt="map of Japan and Air Frame locations" width="145" height="175" onload="MM_swapImage('nav_home','','images/nav_home_f3.jpg',1)" />

Thanks

Rambo Tribble

2:58 am on Jul 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The onload attribute for images, while widely supported in browsers, has never made it into the HTML specification. It's sort of a catch-22.

gniver

12:45 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



Another similar question:
I have sites and have seen other sites that have onload attributes as part of the open body tag. The tag is closed at the end of the onload attributes. Is this incorrect? Should the body tag only include the accepted attributes and put the onload attributes elsewhere?
Here is what I'm referring to:
<BODY bgcolor="FFFFFF" background="/gallery/2003.gif" TOPMARGIN=3 MARGINWIDTH=0 MARGINHEIGHT=0 onLoad="MM_preloadImages('/template/gallery/home/a.jpg','/template/gallery/home/b.jpg','gallery/home/pic.jpg','gallery/home/pic_b.jpg','gallery/home/pic_c.jpg','gallery/home/pic_d.jpg','gallery/home/home.gif','/gallery/home/pic_e.jpg')">

NoLimits

4:36 pm on Aug 6, 2005 (gmt 0)

10+ Year Member



What you could do is,

Make the body tag have an onLoad that runs a JavaScript function that checks the .src of a given image name.

So if you have <img src=blah.jpg name=joe>

then proceed to do an if/then to determine which images are swapped.

Like. . . trigger the below script with onLoad in your body tag.

if(document.joe.src == 'blah.jpg'){
document.window.otherimage.src='swapimage.jpg'
}