最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - Javascript code to open a new window not working in IE - Stack Overflow

programmeradmin1浏览0评论

I have some code on my site that's supposed to open a new window when a user clicks on the link.

Everything works correctly in Chrome and Firefox, but it won't work in IE.

Here's the code I have in the page header:

<script type="text/javascript">
function popopen()
{
    newwindow = window.open("page.html","Title",'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=660,height=620');
}
</script>

And this is the code on the link:

<a href="javascript: popopen()">Click to open the popup</a>

How can I get it to work correctly in IE?

Thanks!

I have some code on my site that's supposed to open a new window when a user clicks on the link.

Everything works correctly in Chrome and Firefox, but it won't work in IE.

Here's the code I have in the page header:

<script type="text/javascript">
function popopen()
{
    newwindow = window.open("page.html","Title",'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=660,height=620');
}
</script>

And this is the code on the link:

<a href="javascript: popopen()">Click to open the popup</a>

How can I get it to work correctly in IE?

Thanks!

Share edited Oct 6, 2013 at 10:20 IsaacL asked Aug 1, 2011 at 16:41 IsaacLIsaacL 6904 gold badges13 silver badges25 bronze badges 10
  • Why not just use target="_blank"? – ayyp Commented Aug 1, 2011 at 16:45
  • I tried it on IE 9, but I'd like it to work on any of the current versions (I think XP still uses IE 8). And I need it to open in a popup window, not in a new tab. – IsaacL Commented Aug 1, 2011 at 16:47
  • Have you tried changing it from "page.html","Title" to 'page.html','Title'? – ayyp Commented Aug 1, 2011 at 16:50
  • 1 This is a pretty dumb question, but is IE blocking the popup? – James Commented Aug 1, 2011 at 16:53
  • Just tried that, didn't help. – IsaacL Commented Aug 1, 2011 at 16:53
 |  Show 5 more ments

1 Answer 1

Reset to default 7

That's because the name of the window (JewishMusic Stream) has spaces! (other browsers allow it, but IE 6, 7 & 8 don't)

you have at line 151:

function popopen()
{
    newwindow = window.open('http://jewishmusicstream./player.html','JewishMusic Stream','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=660,height=620');
}

Should be:

function popopen()
    {
        newwindow = window.open('http://jewishmusicstream./player.html','JewishMusicStream','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=660,height=620');
    }
发布评论

评论列表(0)

  1. 暂无评论