IE下window.open()第二个参数

今天在IE下遇到了一个对于我来说的一个诡异的问题,

window.open("test02.php","just test","menubar=1,location=1");

window.open("test02.php","juestest","menubar=1,location=1");

这本来是一个很简单的句子,第一句在IE下面不起作用,第二句就可以,区别在于第二个参数多了一个空格,自己还2B一样以为发现了IE的bug,结果别人深深的鄙视了。

 

下面是别人的总结:

 

http://stackoverflow.com/questions/710756/ie8-var-w-window-open-message-invalid-argument

 

This is an old posting but maybe still useful for someone.

I had the same error message. In the end the problem was an invalid name for the second argument, i.e., I had a line like:

   window.open('/somefile.html', 'a window title', 'width=300');

The problem was 'a window title' as it is not valid. It worked fine with the following line:

   window.open('/somefile.html', '', 'width=300');

In fact, reading carefully I realized that Microsoft does not support a name as second argument. When you look at the official documentation page, you see that Microsoft only allows the following arguments, If using that argument at all:

  • _blank
  • _media
  • _parent
  • _search
  • _self
  • _top

我算是213到家了,还以为是IE的bug....

think firest,check secound,search third,ask last

使用JavaScript中,父窗口调用子窗口中的函数 及 子窗口调用父窗口中的函数

父窗口调用子窗口函数实现是挺简单的,如下:
var wnd = window.open("XXX.html");
wnd.showDatas(datas);
以上代码中,showDatas是定义在子窗口的函数,datas是父窗口要给子窗口的数据。
需要注意的事,使用open语句打开窗口后,窗口未必能把所有代码全部载入,因此showDatas函数未必调用有效。
如果要有效,可以先把数据传递给子窗口,再在子窗口中延时调用showDatas函数。
如此,父窗口中的代码如下:
var wnd = window.open("XXX.html");
wnd.datas=datas;// 传递数据给子窗口
子窗口中的代码如下:
setTimeout(showDatas(window.datas),1000);// 延时时间可进行调整。
如上,父窗口调用子窗口函数才算完美。

反过来,子窗口要调用父窗口的函数要用opener对象,如:
opener.showMessages(msgs);
以上代码中,showMessages是定义在父窗口的函数,msgs是子窗口要给父窗口的数据。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值