Reputation: 1048
The below code for opening and closing a window is throwing a java script error 'Member not found'. This does not happen in all machines but for certain users with IE 8. winobject.blur() in the following code is throwing the error.
var winobject=null;
winobject = window.open('URL','Name',"width=1,height=1,top=2000,left=2000");
if(winobject!=null){
winobject.blur();
self.resizeTo(screen.availWidth,screen.availHeight);
winobject.close();
...
}
Any help or suggestion to resolve this issue?
Some additional observations- This issue only occurs when a window with the 'Name' already exists. Lets say if the user has already closed the pop up window that was already opened then the code will run fine. Also if I add one more window.open under the current one then no exception gets thrown when blur() is invoked. Not sure why though ?
Upvotes: 0
Views: 2467
Reputation: 12815
if (typeof winobject != "undefined")
I just had an issue with something like this at work today. give that a try, you should be good to go.
Edit:
I have found the following link which appears to explain what is going on. Because you are creating that window
on your own, IE8's "security" is preventing many common actions on it.
My next suggestion as a workaround would be to surround both the winobject.blur()
and winobject.close()
with if (winobject.blur)
and if (winobject.close())
conditionals. Note that you do not have the parenthesis after blur
and close
in the if
's, as you are looking for the presence of the method as opposed to calling the method.
Unfortunately, I'm not sure what the alternatives are that you can use to obtain the same effect. But that should hopefully prevent the error from being thrown.
Upvotes: 1