By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,873 Members | 1,040 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,873 IT Pros & Developers. It's quick & easy.

after prompting I got "unspecified error"

P: n/a
I have the following code in the event onbeforeunload

if ( typeof executingPostBack != 'undefined' && !executingPostBack )
event.returnValue = ""Warning: Modified data has not been saved."";

executingPostBack is a global variable.

I have another function for another event trying to access an object as
follows:

window.location.href = targetObj.href;

everything is OK, but it raises the "unspecified error" when I click
cancel in the popup confirmation window.

anyone gets experience of this ?

thank you very much!

Apr 10 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
so*********@gmail.com wrote:
I have the following code in the event onbeforeunload

if ( typeof executingPostBack != 'undefined' && !executingPostBack )
event.returnValue = ""Warning: Modified data has not been saved."";

^^ ^^
String literals are to be delimited by only one <"> or <'> character.
PointedEars
Apr 10 '06 #2

P: n/a
VK

so*********@gmail.com wrote:
I have the following code in the event onbeforeunload

if ( typeof executingPostBack != 'undefined' && !executingPostBack )
event.returnValue = ""Warning: Modified data has not been saved."";

executingPostBack is a global variable.

I have another function for another event trying to access an object as
follows:

window.location.href = targetObj.href;

everything is OK, but it raises the "unspecified error" when I click
cancel in the popup confirmation window.


Not me: by my observations onbeforeupload handler works smoothly.
"Unspecified error" usually meand that you managed to twist the engine
totally for all 360deg, so it doesn't remember its name and the year
anymore :-)

This line make me suspitious:
window.location.href = targetObj.href;
-not by itself but because you call it "access an object". You are not
accessing an object, you are navigating away from the current page to
the targetObj.href location. If you have onbeforeunload confirmation
already pending for user interaction, add some more pending events...
add a bit of fantasy... I guess it is possible to produce "Unspecified
error". :-)

Could you narrow you problem to some minimum (but self-contained) code?

Apr 10 '06 #3

P: n/a
ooops~

sorry, that's a typo
ignore that, 'cause i am using some code-behind to output the script

Apr 10 '06 #4

P: n/a
thanks for your reply. but why if I click [OK] in the confirmation
window, everything works fine?

my code actually tends to do some hotkey stuffs:

I creates several functions for my links, for example:

function fndnn_ctr407_RelatedData_PageNav_CancelButtonKeyup (event)
{
var b =
document.getElementById('dnn_ctr407_RelatedData_Pa geNav_CancelButton');
Hotkey(event, b, false, false, true, 67);
}
if (document.addEventListener)
document.addEventListener('keyup',
fndnn_ctr407_RelatedData_PageNav_CancelButtonKeyup , true);
else
document.attachEvent('onkeyup',
fndnn_ctr407_RelatedData_PageNav_CancelButtonKeyup );

there are several other functions, ie. for Save button, etc.

they are all attached to the onkeyup event, and I also have an event
for onbeforeunload.

my hotkey function is as follows:

function Hotkey(event, targetObj, ctrlKey, shiftKey, altKey, keycode)
{
if (processing) return;

processing = true;

if (
targetObj
&& event.ctrlKey == ctrlKey
&& event.shiftKey == shiftKey
&& event.altKey == altKey
&& event.keyCode == keycode
)
{
// if we need to post back
if (targetObj.href && targetObj.href.indexOf('doPostBack')>0)
{
executingPostBack = true;
window.location.href = targetObj.href;
}
else if (targetObj.onclick)
{
targetObj.click();
}
else
{
window.location.href = targetObj.href;
}

}

processing = false;
}

When the user clicks [Add] button, I assumes the page is modified, then
I register the onbeforeunload event to prompt the user.
Everything works fine, but it fails when the user clicks [Cancel] in
the confirmation window. The error happens at that line trying to
access targetObj.

any idea?

Thanks

Apr 10 '06 #5

P: n/a
HaHa!

it works

after I use this :

var url = targetObj.href;
try
{
window.location.href = url;
}
catch (e)
{
// do nothing
}

Apr 10 '06 #6

P: n/a
so*********@gmail.com wrote:
it works

after I use this :

var url = targetObj.href;
try
{
window.location.href = url;
}
catch (e)
{
// do nothing
}


Note that this will break in IE < 5.0. Maybe you are looking for

window.location = url;

instead.
PointedEars
Apr 10 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.