窗口打开 Javascript(参数错误)

发布于 2024-12-28 19:43:55 字数 656 浏览 6 评论 0原文

所以我试图在 IE8 中打开一个弹出窗口。到目前为止还没有运气。它告诉我 window.open() 中的参数错误,但是当我查看 window.open() 的所有参数时,一切看起来都是正确的,有建议吗?

<html>
<body>
    <a href="#" id="one">Click Here</a>
<script language="javascript">
var vid1 = document.getElementById('video1');

if(vid1.addEventListener)
{
    vid1.addEventListener('click', function(e){
        videoOne();
    },true);
}
else
{
    vid1.attachEvent('click', videoOne);
}

function videoOne(){
    window.open("http://www.yahoo.com","Case Study 1", 
                "location=1,status=1,scrollbars=1,width=650,height=400");
}
</script>
</body>
</html>

So I'm trying to open a pop up window in IE8. So far no luck. It's telling me I have the wrong parameters in window.open() but when I look at all the parameters for window.open() it all looks right, suggestions?

<html>
<body>
    <a href="#" id="one">Click Here</a>
<script language="javascript">
var vid1 = document.getElementById('video1');

if(vid1.addEventListener)
{
    vid1.addEventListener('click', function(e){
        videoOne();
    },true);
}
else
{
    vid1.attachEvent('click', videoOne);
}

function videoOne(){
    window.open("http://www.yahoo.com","Case Study 1", 
                "location=1,status=1,scrollbars=1,width=650,height=400");
}
</script>
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

虐人心 2025-01-04 19:43:55

Internet Explorer 不支持包含空格的窗口名称。

window.open("http://www.yahoo.com","CaseStudy1", 
            "location=1,status=1,scrollbars=1,width=650,height=400");

Internet Explorer doesn't support window names with spaces in them.

window.open("http://www.yahoo.com","CaseStudy1", 
            "location=1,status=1,scrollbars=1,width=650,height=400");
感情废物 2025-01-04 19:43:55

Quentin 是正确的,尽管 MDN 文档中有关于 window.open< 的更多信息/代码>

新窗口的字符串名称。使用 or 元素的 target 属性,名称可以用作链接和表单的目标。该名称不应包含任何空格。请注意,strWindowName 并不指定新窗口的标题。

Quentin is correct, although there is more information in the MDN docs for window.open:

A string name for the new window. The name can be used as the target of links and forms using the target attribute of an or element. The name should not contain any blank space. Note that strWindowName does not specify the title of the new window.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文