Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Add  onLoad event handler into the BODY tagAdd onLoad event handler into the BODY tag
Previous
 
Next
New Post
12/30/2006 4: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 5: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 5:14 AM
 
Can u please explain this workaround for the body onload event?
Thanks
 
New Post
1/10/2007 11: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 11: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 DNN Platf...Using DNN Platf...Administration ...Administration ...Add  onLoad event handler into the BODY tagAdd onLoad event handler into the BODY tag


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, 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 DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out