Reputation: 57
I want to add a stop-button to my page, which can stop the loading of a page inside an iframe.
Say, if I open www.bbc.com in my iframe, and wan't to stop it from loading half way, without stopping the parent page from loading.
I've found some old posts from 2007-2010 which suggest using JS:
HTML:
<input type="button" value="Stop" onclick="stopFrameLoad(); return false;"/>
JS:
<script type="text/javascript">
function stopFrameLoad()
{
window.stop(); //NS only
document.execCommand("Stop"); //IE only
}
</script>
But it looks like this will only work in IE and NS. Any way to make it work in all browsers?
Also, the above example is from 2010. I was wondering if maybe theres another way to do it now?
Upvotes: 0
Views: 4349
Reputation: 5404
window.stop();
isn't NS only. it works in all browsers with JQuery.
Upvotes: 0
Reputation: 1256
window.stop(); //should work in all major browsers
document.execCommand("Stop"); //is necessary to support IE
See also How to stop page load in html static page
Upvotes: 2