Click to See Complete Forum and Search --> : changing order of execution


dimamo1983
12-13-2003, 11:49 AM
I've got a script in a separte file which i include inside the <head>

It's a menu script. First I use document.write to place all parts of the menu and then the file contains some other functions to move a picture of a truck around the menu.

When the page loads, menu shows up, but the picture doesn't move until the whole page is loaded. I use onLoad inside <body> to call the function that moves the picture.

here's the link:
http://www.osufuturetruck.org

I would like to get the truck moving either while the rest of the page is loading (prefered) or before it starts to load, but not after (as it is right now).

Is there a way I can force this "moving" function to execute before the rest of the page loads?

btw, netscape users won't see the effect, it only works in IE. I know, i know, i should make it compatible, but i just didn't have time yet. maybe later...

thanks,
dima

batfink
12-13-2003, 12:23 PM
take the call to the function out of the body tag and put it:

driveTo('index');

in your js file after the last document.write()

tykst
01-13-2004, 10:43 PM
Sorry to bring this thread up again.
I'm looking for something in this area.. to force a code to execute before the page loads.

I have a static page that contains a lot of images but I would like it to check for flash player and redirect to flash site before the user gets delayed with unecessary loading. I have the following flash detection code in a .js file


function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
var ok=false; document.MM_returnValue = false;
with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
ok=(plugins && plugins[plgIn]);
} else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
else ok=autoGo;}
if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}


and in the body of the static page, the URL to redirect to


<body bgcolor="#000000" text="#666666" link="#FF9900" vlink="#FF9900" alink="#FF9900" onload="MM_checkPlugin('Shockwave Flash','../../../flash/index.htm?mc=image&file=gallery/r010','#',false);show('AA');hide('BB');hide('CC');hide('DD');return document.MM_returnValue"">


so I'm wondering if there's juz something I can insert anywhere that says "if have flash, stop processing and redirect"

Kor
01-14-2004, 03:18 AM
Try using the redirect action in the same check function.

function check(){
if (condition here){
window.self.location = otherURL;
}
}

<body onload="check()">

batfink
01-14-2004, 06:21 AM
Put the link to the js file as the first entry in the <head>

<script type="text/javascript" language="JavaScript" SRC="flash.js"></script>

Then follow it with the call to the function:

MM_checkPlugin('Shockwave Flash','../../../flash/index.htm?mc=image&file=gallery/ r010','#',false);


...and remove the onLoad tag in the main page as it not required now.

Cheers,
Batfink