Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

AspDotNetStoreFront
  Ads  
 


  Sponsors  

Meet Our Sponsors

WebSecureStores -- ASP.NET & DotNetNuke Hosting Solutions
FCKeditor Project
Salaro -- Skins and more
OnyakTech
CrystalTech Web Hosting™
Webhost4life, specialists in DNN hosting
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Configure It! (...  Add onLoad event handler into the BODY tag
Previous Previous
 
Next Next
New Post 12/30/2006 1:58 PM
User is offline Lynn
328 posts
www.seemalta.net
8th Ranked


Add onLoad event handler into the BODY tag 

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.drivewaydesign.eu
 
New Post 12/30/2006 2:26 PM
User is offline John Mitchell
3868 posts
www.snapsis.com
4th Ranked




Re: Add onLoad event handler into the BODY tag 

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.


 
New Post 1/10/2007 2:14 AM
User is offline connect2sandeep
13 posts
10th Ranked


Re: Add onLoad event handler into the BODY tag 
Can u please explain this workaround for the body onload event?
Thanks
 
New Post 1/10/2007 8:00 AM
User is offline John Mitchell
3868 posts
www.snapsis.com
4th Ranked




Re: Add onLoad event handler into the BODY tag 

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.


 
New Post 2/25/2007 8:56 PM
User is offline David Lumley
107 posts
www.go-real.net
9th Ranked


Re: Add onLoad event handler into the BODY tag 
Modified By David Lumley  on 2/26/2007 12:08:32 AM)

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 Previous
 
Next Next
  Forum  General DotNetN...  Configure It! (...  Add 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.

 


Cygnusoft Custom Software
Cygnusoft has been providing cutting-edge custom software solutions for 20 years. Cygnusoft is also a leading start-up incubator, helping our partners build successful new businesses.
www.cygnusoft.com
Digicon: DotNetNuke design and development
Digicon is based in Brisbane, Queensland, Australia
digicon.com.au
Live Visitor Tracking & Live Chat For DotNetNuke
Track your visitors in real time and add live chat for sales & support. Free Trial.
www.whoson.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP