IE 8 onbeforeunload error - Unspecified error |
![]() ![]() |
IE 8 onbeforeunload error - Unspecified error |
Feb 27 2012, 03:22 PM
Post
#1
|
|
|
Member ![]() ![]() Group: Members Posts: 11 Joined: 28-August 06 Member No.: 3,175 |
Hi All,
I'm receiving an unspecified error in IE 8 when I choose to stay on the page when implementing the onbeforeunload javascript function. We are trying to implement a feature warning users that they have unsaved data on the page if they try to navigate away from their current page. Here is an example of a test onbeforeunload function we are using. I've attached screenshots of the errors. CODE var areChanges = true; window.onbeforeunload = function (e) { e = e || window.event; if(areChanges){ // For IE and Firefox prior to version 4 if (e) { e.returnValue = 'IE/FF'; } // For Safari return 'Safari'; } }; The version of IE that I'm getting this error in is 8.0.7600.16385. These menus were compiled with DMB version 4.20.23 Engine: 2.06.023 This error doesn't occur in Chrome, Firefox, or Safari. I have not testing IE 9, but our users use IE 7,8, and 9. Any ideas? Thanks! Matt
Attached image(s)
|
|
|
|
Feb 27 2012, 04:41 PM
Post
#2
|
|
|
Member ![]() ![]() Group: Members Posts: 11 Joined: 28-August 06 Member No.: 3,175 |
Upgraded to version 4.20.25 and Engine 2.06.25 and recompiled. Same error as above.
|
|
|
|
Feb 28 2012, 06:18 PM
Post
#3
|
|
|
Master ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 4,835 Joined: 25-May 02 From: Santiago, Dominican Republic Member No.: 2,332 |
This version of your code should do the trick:
CODE var areChanges = true; window.onbeforeunload = function (e) { e = e || window.event; if(areChanges){ // For IE and Firefox prior to version 4 if (e) { e.returnValue = 'IE/FF'; SetUpEvents(); } // For Safari return 'Safari'; } }; NOTE: Make sure you compile your project with the "Code Optimization" set to "Normal". Setting it to "Max" will prevent this hack from working. -------------------- Xavier Flix
|
|
|
|
Feb 28 2012, 08:13 PM
Post
#4
|
|
|
Member ![]() ![]() Group: Members Posts: 11 Joined: 28-August 06 Member No.: 3,175 |
Hi!
Unfortunately this didn't seem to work. Copied this exact code, cleared IE cache, and tried both Normal and None for Code Optimization. Our menus use the Dynamic API so I can't use Max Optimization. Been using your program since the late 90's and continue to love it! Thanks for all the support. Matt |
|
|
|
Feb 29 2012, 09:04 PM
Post
#5
|
|
|
Master ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 4,835 Joined: 25-May 02 From: Santiago, Dominican Republic Member No.: 2,332 |
In that case I'm not sure if this could be a conflict with the DynAPI...
Could you please test this page: http://xfx.net/test.htm Let me know if you can reproduce the JavaScript error at your end. NOTE: No need to click on any menu item -- refreshing the page should trigger your onbeforeunload code. -------------------- Xavier Flix
|
|
|
|
Mar 1 2012, 12:57 AM
Post
#6
|
|
|
Member ![]() ![]() Group: Members Posts: 11 Joined: 28-August 06 Member No.: 3,175 |
Refreshing http://xfx.net/test.htm in IE 8 does not produce an error for me. I don't see any onbeforeunload in the View Source. Am I missing something?
|
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 19th June 2013 - 05:12 AM |