Results 1 to 3 of 3

Thread: Script conflict onload function

  1. #1
    Join Date
    Feb 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Script conflict onload function

    1) Script Title: Script conflict onload function

    2) Script URL (on DD): http://www.dealermanage.net/loginindex.asp

    3) Describe problem: Hello,
    If you hover over the bottom part of each link the drop down menu will come up.

    I have a problem with conflicting JS scripts.

    The problem is that on some pages I have within the page
    onload="initializePage();" and some pages I do not.

    The conflict occured and did not allow the navigation to show up on the pages that had within the page the onload="initializePage();"

    The page calls on style.js to execute the navigation bar.

    There is a place in the style.js to define onload functions.

    I put initializePage(); in that area and it made the menu appear on all pages as wanted,

    BUT now I get a java script error that says object expected on the pages WITHOUT the function within the page.

    Any suggestions?

    Thanks,
    Dave

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    I haven't looked at the source of Top Menu III extensively yet, but assuming your problem is with multiple onload events conflicting, what you can do is first add the below function to the very end of sniffer.js. This function lets you assign a function to the BODY onload event without having it cancel out/ conflict with the next function that does the same:

    Code:
    function dotask(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
    	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
    	if (target.addEventListener)
    		target.addEventListener(tasktype, functionref, false)
    	else if (target.attachEvent)
    		target.attachEvent(tasktype, functionref)
    }
    So lets say initializePage() is the function you wish to assign to the BODY. You would call it this way instead:

    Code:
    dotask(window, function(){initializePage()}, "load")

  3. #3
    Join Date
    Feb 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    We have it working, thank you for your help.

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
  •