Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    body onload problem

    I have two scripts, one is external, I think I need to unify the two but am not sure how to????
    I've played with the body tag but can only get one script or the other to work and have searched around how to do this but as a bit of a novice am confused by this, I'm sure the answer is quite simple.

    The code:

    Code:
    <script type="text/javascript" src="niftycube.js"></script>
    <script type="text/javascript">
    <!--
    onload=function(){
    startsFunctionOne();
    startsFunctionTwo()
    }
    
    window.onload=function(){
    Nifty("div#container");
    Nifty("div#content,div#nav","same-height small");
    Nifty("div#header,div#footer","small");
    }
    
    function newImage(arg) {
    	if (document.images) {
    		rslt = new Image();
    		rslt.src = arg;
    		return rslt;
    	}
    }
    
    function changeImages() {
    	if (document.images && (preloadFlag == true)) {
    		for (var i=0; i<changeImages.arguments.length; i+=2) {
    			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    		}
    	}
    }
    
    var preloadFlag = false;
    function preloadImages() {
    	if (document.images) {
    		uk1homestay_03_over = newImage("images/uk1homestay_03-over.gif");
    		uk1homestay_06_over = newImage("images/uk1homestay_06-over.gif");
    		preloadFlag = true;
    	}
    }
    //-->
    </script>
    </head>
    <body>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="preloadImages();">

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,169
    Thanks
    19
    Thanked 65 Times in 64 Posts
    The easiest way is to just get one to call the other, whichever one is currently working - at the end, call the other function

  • #3
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Nancy, sounds great, but how do I do that?

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,169
    Thanks
    19
    Thanked 65 Times in 64 Posts
    Have modified your code - all your onload stuff should be in the same function now

    Code:
    <script type="text/javascript" src="niftycube.js"></script>
    <script type="text/javascript">
    <!--
    onload=function(){
    startsFunctionOne();
    startsFunctionTwo();
    Nifty("div#container");
    Nifty("div#content,div#nav","same-height small");
    Nifty("div#header,div#footer","small");
    preloadImages()
    }
    
    
    
    function newImage(arg) {
    	if (document.images) {
    		rslt = new Image();
    		rslt.src = arg;
    		return rslt;
    	}
    }
    
    function changeImages() {
    	if (document.images && (preloadFlag == true)) {
    		for (var i=0; i<changeImages.arguments.length; i+=2) {
    			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    		}
    	}
    }
    
    var preloadFlag = false;
    function preloadImages() {
    	if (document.images) {
    		uk1homestay_03_over = newImage("images/uk1homestay_03-over.gif");
    		uk1homestay_06_over = newImage("images/uk1homestay_06-over.gif");
    		preloadFlag = true;
    	}
    }
    //-->
    </script>
    </head>
    <body>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >

  • #5
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    brilliant thanks so much nancy


  •  

    Posting Permissions

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