SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Javascript onLoad Question
-
Jun 20, 2007, 08:25 #1
- Join Date
- Jun 2005
- Posts
- 5
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Javascript onLoad Question
I'm installing Magic Menus into a DotNetNuke page, therefore I can't touch the body tag which posses a problem as I need to add variables to it to get the menus working. So I'm using JavaScript to get the below working on a page load..
Am I just formatting the below incorrectly?
Code JavaScript:<script type="text/javascript"> function load() { if (window.addEventListener) { window.addEventListener('load', "P7_setMM2('none',1,3,'Sublink 1.2','p7tbdn');P7_trigMM2();P7_autoShowHide(0);MM_preloadImages()", false); } else if (window.attachEvent) { window.attachEvent('onload', "P7_setMM2('none',1,3,'Sublink 1.2','p7tbdn');P7_trigMM2();P7_autoShowHide(0);MM_preloadImages()"); } } </script>
The complete body tag that I WISH I could just put in is:
Code HTML4Strict:<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="P7_setMM2('none',1,3,'Sublink 1.2','p7tbdn');P7_trigMM2();P7_autoShowHide(0);MM_preloadImages();preloadImages();">
Thanks for any help!
-
Jun 20, 2007, 08:47 #2
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I can't see a reason why this shouldn't work:
Code:function load() { P7_setMM2('none',1,3,'Sublink 1.2','p7tbdn');P7_trigMM2();P7_autoShowHide(0);MM_preloadImages(); } window.onload = load;
-
Jun 20, 2007, 10:53 #3
- Join Date
- Mar 2005
- Location
- USA
- Posts
- 5,482
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Event handlers are functions, not strings (except in two special cases).
I recommend Dean Edwards' event manipulation functions.
Then you can simply do this:
Code:addEvent(function(){ P7_setMM2('none',1,3,'Sublink 1.2','p7tbdn'); P7_trigMM2(); P7_autoShowHide(0); MM_preloadImages() });
We miss you, Dan Schulz.
Learn CSS. | X/HTML Validator | CSS validator
Dynamic Site Solutions
Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.
Bookmarks