Forum Moderators: open

Message Too Old, No Replies

Onload within body tag

Can body tag close after onload attributes?

         

gniver

2:31 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



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 acceptable attributes and then 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')">

[edited by: encyclo at 2:41 pm (utc) on Aug. 5, 2005]
[edit reason] Fixed sideways scroll [/edit]

encyclo

7:08 pm on Aug 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ideally, the list of onload images and such should be placed within an external Javascript file, but some scripts for rollover menus, including many from Dreamweaver and other wysiwyg tools list all the preload images within the onload attribute on the body tag of each page.

The latter method is more efficient when dealing with different onlad attributes for each separate page, but you should go external if the images are the same thoughout the site.

gniver

7:20 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



Thanks Encyclo! HTML validator comes back that there is no onload attribute for a body tag. Is there another way around it?

encyclo

7:28 pm on Aug 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Which doctype are you using, gniver? If it is an XHTML one, you need to set all your attributes as lower-case:
[b]onload[/b]
rather than
onLoad
.

gniver

1:09 am on Aug 6, 2005 (gmt 0)

10+ Year Member



It is XHTML and I'll go in and make the change. Thanks again!