我有一个包含链接的网页 - 打开一个显示YouTube视频的新窗口。 它在Chrome中工作正常,但在IE中不起作用。 IE控制台说:SCRIPT5009:"open_win"未定义(我使用的是IE11(
在头部部分,我有:
function open_win(url)
{
new_window = open('','video','width=500,height=390,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
// open new document
new_window.document.open();
// Text of the new document
new_window.document.write("<html><head></head><body style='background-color:'black';margin-top:0; margin-right:0; margin-bottom:0; margin-left:0;'>");
new_window.document.write("<iframe width='560' height='315' src='https://www.youtube.com/embed/-linkRedacted-' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe>");
new_window.document.write("</body></html>");
// close the document
new_window.document.close();
}
在身体里,我有:
<a class="audio" href="javascript:void(0)" onclick="open_win()">
<img alt="See a demo video (opens in New window)" src="images/demo.jpg" width="120" height="110" /></a>
是 IE 安全区域问题还是编码错误?
两件事:
- 你在javascript中使用严格吗?也许如果你正在使用 严格的IE11不喜欢你在不传递函数的情况下调用函数 函数变量。
- JavaScript 是否位于单独的文件中。也许尝试将你的函数复制到你的html上方,看看它是否有区别