views:

578

answers:

1

I'm using window.onback = history.forward(); to prevent users from resubmitting data. I know it's a hack and I don't like it either, but that's not what this question is about. The problem is that the code prevents other pages from going back to the page with the code. Let me clarify.

PageA.aspx has the JavaScript code in it. The user submits PageA, hits Back, and nothing happens. That's good. Now the user clicks a link to PageB.aspx, which does not have the code. When the user clicks the Back button, which should take her to PageA.aspx, it does not. It exhibits the same behavior as if PageB had the no-back JavaScript code.

Here's how I have it implemented in PageA.aspx:

<script type="text/javascript">
window.onback = history.forward();
</script>

I have confirmed that this code is only in PageA.aspx and not in the master, includes, or anything else. This is an ASP.NET 2.0 application running in SharePoint 2007. The browser is IE7.

Any ideas?

+1  A: 

I don't have the time (or SharePoint07) to reproduce you environment and scenario, but what if you put a location test in the JavaScript?

Something like this:

<script type="text/javascript">
if (window.location.indexOf("PageA.aspx", 0) > 0)
{
   window.onback = history.forward();
}
</script>

I can't explain what is happening, but that should help limit the scope of the hack.

PhillFox