...

View Full Version : halt page onload if (browser is IE && JRE is MS)



philipmac
07-12-2007, 10:29 PM
Hi,
If I run a js script -onload saying

document.execCommand("Stop");

execution of the download will stop immediately and the page will not load.

I need to check what browser they are using, and what JRE they have installed. I have this working too onload.

However what I want it to do is to stop execution and put up an alert saying "Please get the Sun JRE" only if the JRE is MS and the browser is MS, and carry on loading in all other cases.

Any idea why document.execCommand("Stop"); only works when it is in the main body of the js file, and does not work for me if it is in a function?

here is some code...

function philStop()
{
browsername = navigator.appName;
var applet = document.myApplet;
var version = applet.getJavaVersion();
if((browsername.indexOf("Microsoft")!=-1) && (version == "MS java runtime thing"))
{
alert("MS Browser plus wrong JRE, goto Sun, get one that is not broken.");
document.execCommand("Stop");
}
}

Arbitrator
07-12-2007, 11:41 PM
I donít know anything about document.execCommand, but you may be able to more reliably detect Internet Explorer via conditional comments (http://www.quirksmode.org/css/condcom.html).

philipmac
07-13-2007, 04:49 AM
Thanks, although I have no problem detecting IE, and no problem detecting the JRE, I have no problem halting the loading of the page either with the
document.execCommand("Stop");
directive, *providing* it is not in a function.
If I just call the command in the main body of the js file, it will work perfectly, but as soon as I put it into a function it stops working.
The rest of the function works perfectly, it pops up an alert saying what it should say, the only thing that doesn't seem to work any more is the stop.


Philip

_Aerospace_Eng_
07-13-2007, 05:29 AM
You have to actually call philStop().

philipmac
07-13-2007, 03:21 PM
You have to actually call philStop().

So, I was calling it onload, but I tried calling it in the body of the js file, and it appears to work.
What was throwing me off was the rest of the function was running properly when I called it onload, apart from the stop.

Sigh.

Thanks Aerospace... back to my perl where I belong.

glenngv
07-13-2007, 05:31 PM
Calling Stop onload will never have an effect as all the elements have been loaded completely so there's nothing more to stop.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum