Results 1 to 3 of 3

Thread: Multiple Onload Problem Using 2 Scripts

  1. #1
    Join Date
    Oct 2005
    Location
    Liverpool, UK
    Posts
    87
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Multiple Onload Problem Using 2 Scripts

    Hi
    I need to get two scripts working together which both use the 'onload' event.

    The 2 scripts are:

    Code:
    <script src="tabbed_pages.js" type="text/javascript">
    </script>
    the external file (tabbed_pages.js) is.....

    Code:
    /* ================================================================ 
    This copyright notice must be untouched at all times.
    
    The original version of this script and the associated (x)html
    is available at http://www.stunicholls.com/various/tabbed_pages.html
    Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
    This script and the associated (x)html may be modified in any 
    way to fit your requirements.
    =================================================================== */
    
    
    onload = function() {
    	var e, i = 0;
    	while (e = document.getElementById('gallery').getElementsByTagName ('DIV') [i++]) {
    		if (e.className == 'on' || e.className == 'off') {
    		e.onclick = function () {
    			var getEls = document.getElementsByTagName('DIV');
    				for (var z=0; z<getEls.length; z++) {
    				getEls[z].className=getEls[z].className.replace('show', 'hide');
    				getEls[z].className=getEls[z].className.replace('on', 'off');
    				}
    			this.className = 'on';
    			var max = this.getAttribute('title');
    			document.getElementById(max).className = "show";
    			}
    		}
    	}
    }


    and :


    Code:
    <script type="text/javascript">
    window.onload = function() {
        setupDependencies('weboptions');
      };
    </script>
    which calls from:
    Code:
    <script src="FormManager.js">
    /****************************************************
    * Form Dependency Manager- By Twey- http://www.twey.co.uk
    * Visit Dynamic Drive for this script and more: http://www.dynamicdrive.com
    ****************************************************/
    </script>
    this is the Form Dependency Manager by Twey (http://www.dynamicdrive.com/dynamici...dependency.htm)


    Can anyone help please?

    Thank you!

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    just have one onload function

    Code:
    onload = function() {
        setupDependencies('weboptions');
    	var e, i = 0;
    	while (e = document.getElementById('gallery').getElementsByTagName ('DIV') [i++]) {
    		if (e.className == 'on' || e.className == 'off') {
    		e.onclick = function () {
    			var getEls = document.getElementsByTagName('DIV');
    				for (var z=0; z<getEls.length; z++) {
    				getEls[z].className=getEls[z].className.replace('show', 'hide');
    				getEls[z].className=getEls[z].className.replace('on', 'off');
    				}
    			this.className = 'on';
    			var max = this.getAttribute('title');
    			document.getElementById(max).className = "show";
    			}
    		}
    	}
    }
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Oct 2005
    Location
    Liverpool, UK
    Posts
    87
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks Vic!

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
  •