开发者

Calling window.close in IE throws null or object not found error

开发者 https://www.devze.com 2023-02-25 17:23 出处:网络
I have a very wierd error cropping up in IE. I am opening a window, with a specific url , and closing it immidiately, using the following code:

I have a very wierd error cropping up in IE.

I am opening a window, with a specific url , and closing it immidiately, using the following code:

openSomething(guid)
{
   my_window = window.open("outlook:"+guid,"mywindow","width=0,hei开发者_如何转开发ght=0");
   my_window.close();
}

This script outputs things as expected, i.e this opens the right outlook mail needed, but IE window shows the error "my_window null or not an object".

Can someone please tell me what is wrong here??


That usually happens when the window is blocked by a/the popup blocker. You'll need to make sure that window.open actually returns a window:

my_window = window.open("outlook:"+guid,"mywindow","width=0,height=0");
if (my_window && my_window.close) {
  my_window.close();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消