#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    27
    Rep Power
    0
    Hi,

    I am trying to use Javascript to stop a web page processing a search when the user hits a cancel button. In Netscape, window.stop() seems to work (in the same way as the Stop button on the browser I guess). However, this does not work in IE. Is there any other method that can be used to get the same result?

    Thanks a lot,
    Matt.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    81
    Rep Power
    15
    You're right, window.stop() is not recognized by IE, but then neither is the stop button

    I don't think you can stop the processing in IE, but you might try one of the following:

    Event.cancelBubble this is IE only and stops EVENT propogation. However, once the event has occurred (onSubmit, onClick or whatever you used to start the download), I'm not sure this will stop it.

    Event.reason IE only. Reason holds the value of the code specifying the status of the data transfer. 0=successful, 1=aborted, 2=error. I don't remember if this is readonly. If it is not, perhaps you can assign a value of 1 to abort the transfer.

    Event.returnValue IE only. I'll quote this one. 'If returnValue is set, its value takes precedent over the value actually received by an event handler. Set this property to false to cancel the default action fo the sourece element on which the event occured.'

    Play with these a bit. I don't see anything else that might work. If they don't do anything to stop the process, it probably can't be done.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by mmonks:
    Hi,

    I am trying to use Javascript to stop a web page processing a search when the user hits a cancel button. In Netscape, window.stop() seems to work (in the same way as the Stop button on the browser I guess). However, this does not work in IE. Is there any other method that can be used to get the same result?

    Thanks a lot,
    Matt.
    [/quote]

  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    27
    Rep Power
    0
    Thanks a lot for that. I'll get busy experimenting...

    Matt.


    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by rkmarcks:
    You're right, window.stop() is not recognized by IE, but then neither is the stop button

    I don't think you can stop the processing in IE, but you might try one of the following:

    Event.cancelBubble this is IE only and stops EVENT propogation. However, once the event has occurred (onSubmit, onClick or whatever you used to start the download), I'm not sure this will stop it.

    Event.reason IE only. Reason holds the value of the code specifying the status of the data transfer. 0=successful, 1=aborted, 2=error. I don't remember if this is readonly. If it is not, perhaps you can assign a value of 1 to abort the transfer.

    Event.returnValue IE only. I'll quote this one. 'If returnValue is set, its value takes precedent over the value actually received by an event handler. Set this property to false to cancel the default action fo the sourece element on which the event occured.'

    Play with these a bit. I don't see anything else that might work. If they don't do anything to stop the process, it probably can't be done.

    [/quote]

  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    27
    Rep Power
    0
    I found a way to do this after a lot of research - use

    document.execCommand("Stop");

    This works in IE.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by mmonks:
    Thanks a lot for that. I'll get busy experimenting...

    Matt.


    [/quote]

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    81
    Rep Power
    15
    Well that's one that doesn't seem to be documented. Thanks, should come in handy.

    Are there any other arguments to this method other than Stop?

    Russ

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by mmonks:
    I found a way to do this after a lot of research - use

    document.execCommand("Stop");

    This works in IE.

    [/quote]

  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    27
    Rep Power
    0
    Russ,

    I actually stumbled across it while looking for something completely different on the MSDN site! Usefully it made the point that this is indeed not documented!

    It didn't mention any other arguments, but it may be worth having a quick search on MSDN and seeing what turns up I guess.

    Cheers,
    Matt.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by rkmarcks:
    Well that's one that doesn't seem to be documented. Thanks, should come in handy.

    Are there any other arguments to this method other than Stop?

    Russ

    [/quote]

  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    27
    Rep Power
    0
    Beware - I have since discovered that this only works in IE5+. Still don't know if there's a way of doing it in older versions of IE....


    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by mmonks:
    Russ,

    I actually stumbled across it while looking for something completely different on the MSDN site! Usefully it made the point that this is indeed not documented!

    It didn't mention any other arguments, but it may be worth having a quick search on MSDN and seeing what turns up I guess.

    Cheers,
    Matt.

    [/quote]

  14. #8
  15. Moderator Emeritus
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Location
    Austin, TX
    Posts
    7,188
    Rep Power
    2265
    Originally posted by mmonks
    I found a way to do this after a lot of research - use

    document.execCommand("Stop");

    This works in IE.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by mmonks:
    Thanks a lot for that. I'll get busy experimenting...

    Matt.


    [/QUOTE]

    3 years later, and this little code excerpt totally helped me complete a project. Thank you, mmonks... if you're still around!
    DrGroove, Devshed Moderator | New to Devshed? Read the User Guide | Connect with me on LinkedIn
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    1
    Rep Power
    0
    And ANOTHER 3 years later... Thanks for saving my brick wall from more cranial abuse (and vice versa :-) ).
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2005
    Posts
    260
    Rep Power
    36
    hmmm... sorry to dig this dusty thread up.. but this seems to not be working.

    I'm using window.document.execCommand('Stop') and I'm not getting a stop. In fact, when I click on the stop button on the browser, the page is still loading. This is in relation to an upload script. The script is uploading the file, and if I want to stop the upload, I click a link that fires of the execCommand. I wonder if something has changed with the browser??

    This is my version of Internet Exploder:
    Version: 6.0.2900.2180.xpsp_sp2_gdr.050301-1519

    Of course everything works well in Firefox (windows.stop()) and the stop button stops the upload.

    Thanks!
    hanji
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    1
    Rep Power
    0

    Smile


    Please use below code for solution to cross browsers.
    I tried it with FF3.5.2, Safari 3.1 and IE 7 and 8 its working fine

    if(navigator.appName == "Microsoft Internet Explorer")
    {
    window.document.execCommand('Stop');
    }
    else
    {
    window.stop();
    }

Similar Threads

  1. Replies: 13
    Last Post: April 25th, 2004, 02:46 PM
  2. Copy() will not work on my system
    By dduck1934 in forum PHP Development
    Replies: 6
    Last Post: February 22nd, 2003, 07:37 AM
  3. Suddenly location.href doesn't work
    By Thomas Regin in forum HTML Programming
    Replies: 5
    Last Post: December 12th, 2002, 06:58 PM
  4. COMMIT WORK and Postgres persistent connections
    By Ted Striker in forum PHP Development
    Replies: 0
    Last Post: July 31st, 2002, 02:39 AM
  5. Javascript form validators do not always work.
    By jodell in forum JavaScript Development
    Replies: 1
    Last Post: August 31st, 2001, 12:56 PM

IMN logo majestic logo threadwatch logo seochat tools logo