This period of time for the first time with the IFRAME, found that the problem is quite many, this time, the main solution is to use a cookie to achieve an IFRAME refresh when staying in the current page, the specific steps are as follows:
1. The current URL must be recorded in each page and stored in a cookie with the following code:
<script>
Record the current page URL
Document. cookie="url=regist_code.html";
</Script>
2. In the main page, read the value of the key ' URL ' in the cookie. The code is as follows:
<IframeId="Index_frame"Name="Index_frame"Src=""
Width="100%"height="88%"allowtransparency="True"Frameborder="0"ranat="Server"></Iframe>
JS Code
<Script>
Variframe =Document.getElementById (' Index_frame ');
IfIframe.GetAttribute (' src ')! =‘‘){
Iframe.SetAttribute (' Src ',' index.html ');//To determine the first time you enter the page, the first page is displayed, see PS
}
functionGetCookie (URL)
{
if (Document.Cookies.Length>0)
{
VarStrcookie=Document.Cookies;
Cutting multi-Cookie into multiple name/value pairs
VarArrcookie=Strcookie.Split"; ");
Iterate through the cookie array and process each cookie against
ForVarI=0;i<Arrcookie.Lengthi++) {
VarArr=arrcookie[I].Split"=");
//finds a cookie with the name UserID and returns its value
if (Url==arr[< Span style= "COLOR: #0000ff" >0]) {
return ( arr[1]);
break;
}
}
}
}
iframe.setattribute ( ' src ', getcookie ( ' URL '));// Reset get URL, implement refresh display current page
</script ;
PS: This example is to put all the pages, including the homepage, so the first time to enter the page needs to set the IFRAME SRC, if directly in the src write src= "index.html", when the page refresh there will be a delay, Causes the page to appear index.html content before displaying the contents of the other currently clicked page.
Use cookies to make an IFRAME refresh while staying on the current page