My webpage has a lot of images, and the server is not very good. Therefore, one or two images cannot be displayed after each page is opened, but all images can be displayed after the page is refreshed, I believe everyone has encountered this problem. Next we will introduce the solution in detail.
The Code is as follows:
Script
Function window. onload (){
If (location. href. indexOf ('# reloaded') =-1 ){
Location. href = location. href + "# reloaded"
Location. reload ()
}
}
Script
-----------------------------------------------------------------------------
My webpage has a lot of images, and the server is not very good. Therefore, one or two images cannot be displayed after each page is opened, but they can all be displayed after being refreshed.
I don't want anyone browsing the page to click the "refresh" button every time. How can I add some code to the page so that the page will be automatically refreshed once it is opened?
---------------------------------------------------------------
Add the following code Between
---------------------------------------------------------------
Three methods:
1. script
The Code is as follows:
Function refreshPage (the_duration)
{
SetTimeout ("self. location. reload ();", the_duration * 1000 );
}
Self. onload = function (){
RefreshPage (1); // The value 1 indicates the interval of 1 second and not refreshed. You can change it to the one you want.
};
Script
2.
3.
Refresh only once:
---------------------------------------------------------------
It's late. The upstairs brother is right.
---------------------------------------------------------------
The above method is to refresh every five seconds, which puts a lot of pressure on the server. If a large number of requests are connected and the server is not very good, it is likely to become the server's host.
Therefore, a better method is to use Javascript. After loading, refresh the page with the following code:
The Code is as follows: