【发布时间】:2019-01-16 06:26:27
【问题描述】:
我有一个包含链接的网页 - 打开一个显示 YouTube 视频的新窗口。它在 Chrome 中运行良好,但在 IE 中它不起作用。 IE 控制台显示:SCRIPT5009: 'open_win' is undefined(我使用的是 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 安全区域问题,还是编码错误?
【问题讨论】:
-
太棒了 - 你有答案 - 谢谢!知道为什么找不到它(这肯定是这样的函数应该驻留的地方吗?)
-
发布的解决方案似乎消失了;?是将功能从头部转移到身体部分。
-
它应该可以在任何地方工作。
-
代码在
<script>...</script>里面吗? -
好吧@Barmar - 解决方案(似乎已经从视图中消失了;?)说IE11在头部找不到功能。所以,我把它移到 并且它现在可以工作了。而且,很高兴能说明这一点……它在
标签: javascript html cross-browser