HomeHomeUsing DotNetNuk...Using DotNetNuk...Administration ...Administration ...Add  onLoad event handler into the BODY tagAdd onLoad event handler into the BODY tag
Previous
 
Next
New Post
12/30/2006 1:58 PM
 

Hello

I would like to add some javascript to a page on my site but the script requires that I add an onLoad event handler into the BODY tag.

How can I do this?

DNN 4.4.0

Thanks

Regards

Lynn


www.seemalta.net
 
New Post
12/30/2006 2:26 PM
 

Hi Lynn,

You can execute your script onLoad by adding the following cross-browser code to the top of your Javascript file:

if (window.addEventListener)
{
    window.addEventListener("load", Your_Function_Name, false);
}
else if (window.attachEvent)
{
    window.attachEvent("onload", Your_Function_Name);
}

 

Just replace the Your_Function_Name with the name of the function you want to execute, no quotes or parens.


DotNetNuke Modules from Snapsis.com
 
New Post
1/10/2007 2:14 AM
 
Can u please explain this workaround for the body onload event?
Thanks
 
New Post
1/10/2007 8:00 AM
 

I'm not sure what I can explain.

The code above is Javascript that will run in the global space (outside a function), which will add a function to an event listener.
When the page loads, the javascript will run, and then your Javascript funtion will run.

If you want the details there is a good explaination here.

If there is a specific question I can answer that too.


DotNetNuke Modules from Snapsis.com
 
New Post
2/25/2007 8:56 PM
 

I have managed to get the JavaScript for my Marquee working now but have come across some problems in moving from Firefox to IE7

the code to addEventListener worked OK in firefox but I have found a tighter methos of doing it

 if (typeof window.addEventListener != "undefined" ) {

window.addEventListener("load", populatemarq, false); 

}else if (typeof window.attachEvent != "undefined" ) { 

window.attachEvent("load", populatemarq, false);

} else { if (window.onload != null) { 

var oldOnload = window.onload; window.onload = function ( e ){ oldOnload ( e ); populatemarq();};

 }else

window.onload = populatemarq;}

This code seems to load OK but still doesnt fire the populate function in IE7 - any Ideas

Should I look at the function  - AddBodyOnloadEventHandler( MyBase.Page, "populatemarq")

and if this is correct how do I access it (currently it says AddVodyOnloadEventHandler is not declared ???)


Dave DNN 4.3.5 IIS - 6 ?? SQL Server 2005
 
Previous
 
Next
HomeHomeUsing DotNetNuk...Using DotNetNuk...Administration ...Administration ...Add  onLoad event handler into the BODY tagAdd onLoad event handler into the BODY tag


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

Attend A Webinar
Free Demo Site
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

DotNetNuke Scoop!

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft .NET. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates the DotNetNuke Store where users purchase third party apps for the platform.