javascript - When using window.location.href to jump to a page, how to achieve the loading effect before the new page is fully loaded?
漂亮男人
漂亮男人 2017-05-19 10:45:07
0
4
1716

Using window.location.href to make page jumps, how to achieve the loading effect before the new page is completely loaded?

漂亮男人
漂亮男人

reply all(4)
阿神

If it were me, I would do this:
1. You can add the loading effect to the page that window.location.href jumps to.
2. If there is no way to modify the content of the window.location.href jump page, I will use ajax to request the page, insert the html into the current page, and load it at the time of requesting the page.

给我你的怀抱

The location.href jump will cause the page to be completely refreshed, which has nothing to do with the previous page.

The page is parsed from top to bottom. If loading is placed at the top, it will naturally be loaded first. However, if images are used, the images are downloaded asynchronously, so the order cannot be controlled and the images may pass by in a flash.

If you must see it, you can use non-picture loading, then hide other content first, only the loading appears, and then display it after the loading is completely triggered.

PHPzhong

Using window.location.href去完成页面的跳转,这是瞬发的,所以在跳转页(A)做loading is unreliable.

Soloading效果是应该放到被跳转页(B)来做。但是img标签src属性是异步的,如果不是用js去控制的话,那么这时你也无法保证img加载的时间,这个时候可以试着用直接写进模板文件当中的cssloading效果来做,等页面加载完了之后关掉cssloadingeffect.

迷茫

Do you have any compatibility requirements for this? You can also add a loading layer to the jump and control it with js
I wrote an example:
https://www.mnzld.net/demo/lo...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!