开发者

How to prevent flickering on click of browser back button

I am working on Asp.Net application.I wrote the below JavaScript code to prevent the user to not going to login page on click of browser back button when he logs into the application.It is working fine for me,but from the homepage when i click on browser back button,the flickering appears due to post back.How to prevent the flickering.

Please provide the solution.

function preventBack()
{
    window.history.forward();
}

setTimeout("preventBack()", 0);

wi开发者_StackOverflow社区ndow.onunload=function()
{
    null;
} 


Pages flicker on navigation. It's the web. Everyone is used to it. Don't bother trying to “fix” it.

Flicker is absolutely the least of your problems. Trying to break the back button is enormously user-hostile and typically a sign that you've messed something up. It doesn't even work all the time (eg. middle-click-back), and it breaks other functionality (eg. but I want to go several pages back!). Don't do this.

If you simply don't want a login page to remain in page history, you could make it perform an AJAX login process (setting a cookie) and then either location.replace to go to the next page, or, better, have the login page returned on any attempt to access a login-required page, and simply location.reload to try to access the page again after setting the login details.

But really, no-one cares if hitting ‘back’ takes them back to a login page that is now no longer relevant because they're logged in. That's the way 99% of web sites work and users will expect it.


This code is absolute problematic !!!

I am sure that you get a lot of your system resource and speed, and a dead loop inside the page...

Try to find something else to solve your problem, witch is ? probably what ?, when user go back to the logging page, just see that is a verified user and redirect him to the correct page.

Avoid this code !!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜