javascript window.open 错误仅在 IE 中 - 无效参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5790924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 18:20:57  来源:igfitidea点击:

window.open error only in IE - Invalid argument

javascriptwindow.openinvalid-argument

提问by Chris Bornhoft

I have a simple calendar popup window come up when a date on the calendar is clicked. The code below works in Opera, FF and Chrome but not in IE6-8. It comes up with the Error on Pageat the bottom and shows the error invalid argument.

单击日历上的日期时,会出现一个简单的日历弹出窗口。下面的代码适用于 Opera、FF 和 Chrome,但不适用于 IE6-8。它出现Error on Page在底部并显示错误invalid argument

<div class="day-number">1</div>
<td class="calendar-day" onclick="window.open('http://www.cal.com/admin/editevents.php?day=2&month=4&year=2011', 
'Edit Events', 'scrollbars=1,width=600,height=475');">

Could someone help me out and spot what I'm doing right but wrong according to IE?

有人可以帮助我并根据 IE 发现我在做什么是对还是错?

回答by Pekka

The window name shouldn't have a space. Try EditEvents.

窗口名称不应有空格。试试EditEvents

回答by Dung Nguyen

window.open(theURL,winName,features);

ex: window.open('google.com','Edit Events','width=100'); //false

前任: window.open('google.com','Edit Events','width=100'); //false

window.open('google.com','EditEvents','width=100'); //True

=> Edit Events //false

=> 编辑事件 //false

EditEvents //true

编辑事件 //true

=>winName doesn't have spaces.

=>winName 没有空格。