javascript - Details about window.stop() - Stack Overflow

I just came across the window.stop()The stop() method is exactly equivalent to clicking the stop button

I just came across the window.stop()

The stop() method is exactly equivalent to clicking the stop button in the browser. Because of the order in which scripts are loaded, the stop() method cannot stop the document in which it is contained from loading, but it will stop the loading of large images, new windows, and other objects whose loading is deferred. .stop

I am wondering:

  1. What do 'windows' and 'other objects whose loading is deffered' refer to? Can somebody give me a practical example?
  2. If I append an image to the body and call window.stop() when 30% has been loaded, and then append the same image at a later time; will the latter image only have 70% left load?

I just came across the window.stop()

The stop() method is exactly equivalent to clicking the stop button in the browser. Because of the order in which scripts are loaded, the stop() method cannot stop the document in which it is contained from loading, but it will stop the loading of large images, new windows, and other objects whose loading is deferred. https://developer.mozilla/en-US/docs/Web/API/Window.stop

I am wondering:

  1. What do 'windows' and 'other objects whose loading is deffered' refer to? Can somebody give me a practical example?
  2. If I append an image to the body and call window.stop() when 30% has been loaded, and then append the same image at a later time; will the latter image only have 70% left load?
Share Improve this question asked May 5, 2014 at 20:35 MingMing 7844 gold badges15 silver badges27 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

What do 'windows' and 'other objects whose loading is deffered' refer to? Can somebody give me a practical example?

new windows could be iframes or regular frames. Scripts themselves can be marked as defer which loads them after the document and after other inline scripts so these could also be stopped with window.stop(). So practical examples of objects that might have their loading stopped are: iframes, embedded objects (like Adobe Flash), scripts marked defer and images. The idea here is that if you're going to call window.stop() from a script in the page, it can only apply to resources that have not yet pleted loading. By definition, at least part of the document and your script have already pleted loading or the script wouldn't be running so you could call window.stop() so it is primarily going to apply to resources that are loaded later in the load process such as the ones above.

If I append an image to the body and call window.stop() when 30% has been loaded, and then append the same image at a later time; will the latter image only have 70% left load?

The browser cache is very unlikely to cache 30% of an image and then resume loading only the remaining 70% the next time you ask for that resource. Most caches just refuse to cache an object if it is not pletely loaded. In any case, this would be entirely browser dependent as this type of behavior of the cache is outside of the standards.

What do 'windows' and 'other objects whose loading is deffered' refer to? Can somebody give me a practical example?

I use to do a practical to keep window calm when page reloading like this example.

    window.stop();
    (do some staff here..)
    window.location.reload(true);

The window will automatically active by itself when page is reloaded.
So it stop only the browser, not the script.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744377218a4571244.html

相关推荐

  • javascript - Details about window.stop() - Stack Overflow

    I just came across the window.stop()The stop() method is exactly equivalent to clicking the stop button

    7天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信