1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Html body tag modification?

Discussion in 'HTML, Graphics & Programming' started by MadMossy, 12 May 2010.

  1. MadMossy

    Soldato

    Joined: 25 Oct 2004

    Posts: 7,151

    Location: Sunny Torbaydos

    Hiya,

    Working on a CMS type site at the moment and one of the JS scripts i want to use requires that the <body> element have an onload function for it to function.

    Thing is i cannot add the onload function to it as the <body> element is created by the CMS itself, I only have control of the content between the <body></body> elements.

    Is it possible to alter the <body> element through js to add the onload part ?
     
  2. SimonCHere

    Wise Guy

    Joined: 24 Jun 2008

    Posts: 1,168

    Code:
    function init() {
    //do stuff
    }
    window.onload = init;
    
     
  3. GravyMonster

    Capodecina

    Joined: 18 Oct 2002

    Posts: 14,508

    Location: The land of milk & beans

    Also, if you are using a framework such as MooTools or jQuery you'll need to use their methods of hooking into the onload event so as to avoid conflicts.
     
  4. MadMossy

    Soldato

    Joined: 25 Oct 2004

    Posts: 7,151

    Location: Sunny Torbaydos

    The CMS uses prototype/scriptaculous.
     
  5. sist_si

    Wise Guy

    Joined: 28 Nov 2004

    Posts: 1,224

    Location: Birmingham

    Event.observe(window, 'load', function() {
    //do your stuff
    });

    (for prototype)
     
  6. MadMossy

    Soldato

    Joined: 25 Oct 2004

    Posts: 7,151

    Location: Sunny Torbaydos

    Actually run into another problem with javascript.

    Using a chained drill down menu script i need to initiate them using

    Code:
    initListGroup('category_list', document.csv_genfrm.["csvdata[type]"], document.csv_genfrm.["csvdata[compression]"]);
    
    But because of how my form data is stored (php/sql session) and how i process the data using a foreach loop javascript doesnt like the [] around my form input names.

    Is there anyway to get around this, i've tried the usual " etc around the data but it wont work.
     
  7. MadMossy

    Soldato

    Joined: 25 Oct 2004

    Posts: 7,151

    Location: Sunny Torbaydos

    never mind figured it out by adding elements["variable[]"] to the javascript