This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10399|Reply: 0

[JavaScript] javascrip{filter}t:the difference between history.go() and History.back().

[Copy link]
Posted on 11/18/2016 10:18:36 PM | | |



In a C# web program, such as writing back to the previous page code for a page button

this. RegisterClientscrip{filter}tBlock("E", "<scrip{filter}t language=javascrip{filter}t>history.go(-2); </scrip{filter}t>");

Among them, history.go(-2) should be written as -2, because the page has been refreshed once before the button event is triggered, so it should be -2.

Response.Write("<scrip{filter}t language=javascrip{filter}t>history.go(-2); </scrip{filter}t>");

It should also be written as "-2" here. It's different from writing a script directly. history.back()is 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's forward and backward functions.
The specific use depends on when you need it. For example, the verification of user registration is background verification, which can be used when it does not meet the requirements, which can ensure that users do not enter data repeatedly to the greatest extent.
For example: loading a page:
   function onLoadPage(){
     if(event.srcElement.tagName=="SPAN"){
         oFrame=top.window.middle.frames[2];
         oTxt=event.srcElement.innerText;
         switch(oTxt){
             case "Forward":
                 oFrame.history.go(1);
             case "back":
                 oFrame.history.back();
             case "Brush New":
                 oFrame.locatio{filter}n.reload();
         }
     }
}


Open a jsp page, and it must have been refreshed with a client script.
Javascrip{filter}t several ways to refresh a page:
1 history.go(0)
2 locatio{filter}n.reload()
3 locatio{filter}n=locatio{filter}n
4 locatio{filter}n.assign(locatio{filter}n)
5 document.execCommand('Refresh')
6 window.navigate(locatio{filter}n)
7 locatio{filter}n.replace (locatio{filter}n)
8 document. URL=locatio{filter}n.href




Previous:Discuz Cloud Platform to Site Timeout
Next:How to use SqlConnection correctly, is SqlConnection thread safe?
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com