Results 1 to 4 of 4

Thread: body onLoad creates conflicts on pages not utilizing the script

  1. #1
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default body onLoad creates conflicts on pages not utilizing the script

    1) Script Title: Chained Selects

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ects/index.htm

    3) Describe problem: The script calls for editing the <body> tag to look like:
    <body onLoad="initListGroup('series', document.forms[0].seriesName, document.forms[0].height, 'cs')">

    My problem is that the site is created using templates in Dreamweaver, which means that the only way I can find of editing the body tag for the one page I need this script on, is to edit it in the master template. Doing so changes the <body> tag for every page on the site, which is fine, except that now each page shows an error marker with the following error.

    Error: 'document.forms.0seriesName' is null or not an object

    Is there a way to either fix this error message, or to add the onLoad to the body tag of just the one page I need it on, without changing every page in the site, while still utilizing a template?

    Any help you can give me, would be greatly appreciated.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That's stupid. I don't know DW, but there must be an easy way to have one page be a little different. In any case though, until you figure that out, try this:

    Code:
    <body 
    onload="if(document.forms[0]&&document.forms[0].seriesName){
    initListGroup('series', document.forms[0].seriesName, document.forms[0].height, 'cs')
    }">
    - John
    ________________________

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

  3. #3
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    John,

    Thank you so much for your post, your solution worked perfectly!

  4. #4
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    put this in the head:
    Code:
    <script type="text/javascript">
    function run() {
    initListGroup('series', document.forms[0].seriesName, document.forms[0].height, 'cs');
    }
    document.getElementsByTagName("body")[0].onLoad=run;
    </script>
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

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
  •