Geeks With Blogs
kazim mehdi


I have page that was hosted inside the iframe and I want to redirect the parent window when a user click a button inside the child page.

For that I added the following code in the Button’s click event as I have to execute some server side code before redirecting.


Page.ClientScript.RegisterStartupScript(this.GetType(), RedirectKey, string.Format(" = ‘’;", url), true);



Above mentioned code worked great but when the user used the browser’s back button to go back to the previous page. It went there for a moment and

redirect to the location that I put inside the above javascript.



I googled and search specifically on the stackoverflow and found the similar post and thanks peter-bailey he post the solution here. And the solution is using replace method

instead of just setting href.


top.location.replace it didn’t produce history.

Page.ClientScript.RegisterStartupScript(this.GetType(), RedirectKey, string.Format("top.location.replace('');", url), true);
Posted on Friday, June 10, 2011 11:18 AM , Javascript | Back to top

Comments on this post: Remove/Disable javascript when using browser's back button

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © kazim sardar mehdi | Powered by: