views:

82

answers:

2

Hi...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);

window.onunload=function()
{
    null;
} 
+1  A: 

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 !!!

Aristos
+2  A: 

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.

bobince
Hi bobince..thanks for the reply...After i googled a lot,i didn find any solution for this fix.I let my application to work the same way.
karthik