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

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


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

07-13-2007, 12:41 AM
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).

07-13-2007, 05: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
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.


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

07-13-2007, 04: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.


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

07-13-2007, 06: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.