...

View Full Version : body onload problem



monkfish687
10-25-2006, 01:04 PM
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:


<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();">

NancyJ
10-25-2006, 01:16 PM
The easiest way is to just get one to call the other, whichever one is currently working - at the end, call the other function

monkfish687
10-25-2006, 01:29 PM
Thanks Nancy, sounds great, but how do I do that?

NancyJ
10-25-2006, 02:37 PM
Have modified your code - all your onload stuff should be in the same function now



<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" >

monkfish687
10-26-2006, 10:22 PM
brilliant thanks so much nancy:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum