<body> tag "surgery"

valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2004-08-02 08:06

Someone from the xaraya.devel list proposed the following:

Quote:
(me) wrote:
> I need to set the <body onLoad onUnload> properties variably.
> how?

Look at javascript i used in xaraya.com which allows us to avoid performing surgery on the body tag (bad anyway) and to make the actions
your module require both theme-independent and gentle to other modules which may also want to pass their javascripts along - attaching
events is a standard/modern way to deal with the problem, i believe..

[snip]

if (document.all&&window.attachEvent) { // IE-Win
     window.attachEvent("onload", nav_hover);
     window.attachEvent("onload", setExternalLinks);
} else if (window.addEventListener) { // Others
     window.addEventListener("load", setExternalLinks, false);
}

[snip]

HTH,
AndyV.

what about changing this in g2?

 
rossr

Joined: 2002-08-19
Posts: 28
Posted: Mon, 2004-08-02 08:30

I'm for it! :)

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2004-08-03 04:55

I tried doing this in G2 last night and didn't get it working, and ran out of time. Right now I'm busy working on optimizations so this isn't at the top of my list. But I passed it off to mindless and I'm confident that he'll get it working (he's very good at this kind of thing).

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2004-08-23 15:14

I have removed the onload/onunload tags in global.tpl and used the javascript as shown above for hybrid and slider layouts.. worked fine for me on the few browsers I tried..

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2004-08-23 17:58

thanks, great :)