Using Internet Explorer (don't appear to have an issue in FireFox) the following code will occassionally raise an
Error: Access is denied.
Code: 0
The line in question is the second window.open.
currentDialog = window.open("error.html", name, "width=20 height=20 left=50 top=70", true);
if (currentDialog != null)
currentDialog.close();
currentDialog = window.open("about:blank", name, "width=20 height=20 left=50 top=70", true);
However if a delay is introduced - not sure how long is really necessary or about consistency - then the first window opens and closes and the second window will open successfully.
currentDialog = window.open("error.html", name, "width=20 height=20 left=50 top=70", true);
if (currentDialog != null)
currentDialog.close();
//Small delay to allow slow addons enough time to process OnLoad/OnQuit()
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < 300);
currentDialog = window.open("about:blank", name, "width=20 height=20 left=50 top=70", true);
Not happy having some random length of time.
Is there some other way to ensure that currentDialog.close();
doesn't return until it is properly disposed of such that a new window with the same name can be created successfully within the same function as demonstrated above?
Background
The window is used for displaying a special selection dialog which should be modal. To get modal when the window is created onfocus and onunload events are added so that if the focus changes to the main page the focus is set back to the selection dialog and if the main page is closed then the modal dialog is closed.
When progressing through the selectors quickly sometimes the unhooking of the 1st dialog happens after the attempted hooking of the 2nd dialog and so the dialog doesn't have an appropriate modal action.
Perhaps a better thing to solve: Is there perhaps some alternate way to get this modal dialog action and avoid the need for 'creating' the intermediate error page?