I am using the onbeforeunload client-side event to prompt a user when leaving a page after they have made changes, as discussed in this article of mine: Using ASP.NET to Prompt a User to Save When Leaving a Page. The problem I am having is with the page unloading via eval. Specifically, I am using telerik r.a.d. menu, which redirects users to another page via script like:
eval('window.location.href='url of menu item');
When a user attempts to leave the page via a menu option, they get the prompt, as expected, but if they click Cancel there is a script error: Unspecified error on the line number of the eval() function call. This works just fine in Firefox.
I created a VERY simple page to test this out and confirm that it is the eval() function. The page below, when visited through IE, displays the prompt and if I click Cancel I get the same Unspecified error. ![Sad [:(]](/emoticons/emotion-6.gif)
<script>
function foo()
{
return "bar";
}
window.onbeforeunload = foo;
eval('window.location.href=\'http://www.google.com\'');
</script>
I was unable to find any info via Google as to if this is a well-known bug or if there are any workarounds. Any ideas/suggestions/comments most appreciated. (I'm posting this in the telerik forums as well; hopefully there's an easy way to get rid of those eval() statements, but I doubt it...
)
TIA