Results 1 to 3 of 3

Thread: Add onload to body tag

  1. #1
    Join Date
    Nov 2005
    Location
    Austin TX,US
    Posts
    71
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Add onload to body tag

    Hi,

    It looks like a simple question but I haven't figured out how to do it yet.
    I have a javascript function that needs to be activated with onload in the body tag.

    Everything [html and javascript] works fine on my desktop and my own server - where I have access to change the <body> tag. But where I'm working for right now, using CMS, and I don't have access to change the body tag. How do I get around it and dynamically add onload to the body.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,072
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    It depends upon what you do have access to, and if there is only one event to perform onload or not. If you have access to edit the script used by the page and there are no other onload events for that page either coded in another script you have for that page or in some other script assigned to that page by anyone/anything else, you can just put your onload in your script code. Say you wanted to have:

    HTML Code:
    <body onload="doSomething();">
    Instead, in your script you could put:

    Code:
    window.onload = function(){
    doSomething();
    };
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,626
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    But where I'm working for right now, using CMS, and I don't have access to change the body tag
    May be your CMS provides another means of achieving the effect you want. Which CMS you use?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •