The QA Team detected many 500 errrors in the application through tealeaf and avicode, so this problem was almost solved in the past two weeks. Different errors such as reproduce can be attributed to the browser's pressing back button and the keyboard's backspace, it is necessary to prevent the page from going back.
Of course, relatedArticleIn fact, an article is turning around. Basically, there are three solutions:
1) set the webpage to expire (on the server side)
2). javascript: window. History (client)
3). For the backspace of the keyboard, use window. event to filter the backspace. Of course, you must consider retaining the delete function for the input control.
<SCRIPT type = "text/JavaScript">
Function backspace (){
If (event. keycode = 8 & event. srcelement. tagname! = "Input" & event. srcelement. type! = "Text ")
Event. returnvalue = false;
}
If (navigator. appname = "Microsoft Internet Explorer "){
Window. History. forward (1 );
}
Else // if it is Mozilla
{
Window. History. Forward (-1 );
}
</SCRIPT>
Below is my attempt:
1) First, if the webpage expires:
Once a webpage expires, it means that every time the page is refreshed, You need to obtain all the webpage resources from the server. At this time, if you use the browser's backend button, the whole page will be reloaded, which is equivalent to a GET request. Therefore, the onload event and onloadcompleted event will be executed for the corresponding page.
If you fail to obtain the required resources on the onloadcompleted event page, an error indicating that the webpage has expired is displayed. However, no matter how *** is added to the page, the page expiration error cannot be reproduced,
2) execute the script for the onload of the page client: Windows. History. Forward (1). Others say this method is not perfect, but there is no reason to handle it. I am talking about window. history. forward (1) can cover almost all scenarios, but it is a strange thing that when all the backdrops pass through a page, it will stop and will not continue to forward to the original page. We thought this was the key to solving 500 errors, but a casual chat reminds us that if we didn't click the hind-leg button, we chose the page in the history list, what should I do? I have two ideas to solve this problem.
A) obtain the index on the page selected in historylist, and then use Windows. history. froward (INDEX), read the information, and finally explain on msdn that Microsoft will not expose windows because it is in security. the actual URL and index in the history object cannot obtain the specific information of the historylist webpage.
B) record the URL of the previous page and use Windows directly. location. href: it is not difficult to record the URL before the record is backed up. <% =%><%#%> can all be done, but the problem arises. How to distinguish the get reque of a webpage from the result of the rollback, there seems to be no solution!
But when I explore A and B, I think of two questions.
1) about windows... history.Forward (); if there are only five pages in windows. History list, but I put windows... history. Forward (100), what will happen.
2) If I select a page W whose distance from the current page is not 1 in the History listHow does indows... history. Forward (1) Work?
Explanation:
1) In fact, windows .. history. Forward (100) and Windows .. history. Forward (1) have the same effect.
How does windows .. history. Forward (1) Work?
Windows .. history. Forward (1) always uses Windows. History. LYou can buy all your pages in ist until the page can no longer go forward. For Windows. history. list. when length = 5, No matter on which page the history and forward (1) are initiated, the current page is displayed. Therefore, the page is blocked, but the disadvantage is that there are a lot of additional HTTP requests, because a page needs to be rolled back.
Another strange problem: in one of our applications, I found that windows. History. forwaRd (1) will go to a page and stop. As a result, the page after that page cannot implement the function of organization backend. I accidentally discovered that for Windows. history. the forward (1) page will actually execute the oninit, onload, onloadcomplete events, I am very puzzled, why windows. history. forward triggers server events because cache expiration is set in the base class so that page resources are retrieved from the server each time.
Therefore, the page expiration cannot be the same as windows. History. Forward.Used