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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    halt page onload if (browser is IE && JRE is MS)

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

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,316
    Thanks
    29
    Thanked 280 Times in 274 Posts
    I don’t know anything about document.execCommand, but you may be able to more reliably detect Internet Explorer via conditional comments.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You have to actually call philStop().
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    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.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Calling Stop onload will never have an effect as all the elements have been loaded completely so there's nothing more to stop.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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