Home > Web Front-end > JS Tutorial > Back and refresh implementation methods in javascript

Back and refresh implementation methods in javascript

高洛峰
Release: 2016-12-07 11:11:34
Original
1157 people have browsed it

<input type=button value=刷新 onclick="window.location.reload()">
<input type=button value=前进 onclick="window.history.Go(1)">
<input type=button value=后退 onclick="window.history.go(-1)">
<input type=button value=前进 onclick="window.history.forward()">
<input type=button value=后退 onclick="window.history.back()"> 后退+刷新<input type=button value=后退 onclick="window.history.go(-1);window.location.reload()">
Copy after login

In a C# Web program, if you write code to return to the previous page for a page button

this.RegisterClientScriptBlock("E", "");

Also write "-2" here. It is different from writing scripts directly. history.back() is to go to the previous page
i=1
history.go(i) to a specified page

If it is history.go(0), it is to refresh these two JS codes, which is equivalent to IE Forward and backward functions.

The specific use depends on when you need it. For example, the verification during user registration is background verification. This can be used when the requirements are not met, which can minimize the need for users to repeatedly enter data.

For example: Loading page:

  function onLoadPage(){
   if(event.srcElement.tagName=="SPAN"){
     oFrame=top.window.middle.frames[2];
     oTxt=event.srcElement.innerText;
     switch(oTxt){
       case "前 进":
         oFrame.history.go(1);
       case "后 退":
         oFrame.history.back();
       case "刷 新":
         oFrame.location.reload();
     }
   }
}
Copy after login

Open a jsp page, it must be refreshed with client script.

Several ways to refresh the page in Javascript:

1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refresh')
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template