I'm trying to use javascript to open a popup window. It works in Chrome but not in IE or Firefox

喜你入骨 提交于 2021-01-27 14:23:14

问题


I'm trying to use javascript to open a popup window. It works in chrome but not in IE or Firefox.

Here is my code for the head section:

<head>
  <script type="text/javascript">

function newPopup(url) {
    popupWindow = window.open(
        url,'popUpWindow','height=400,width=400,left=550,top=200,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
</script>
</head>

And my code in the body section:

 <body>
    <a href="javascript:newPopup('buy-now/ambush-jacket.html');" target="_new"><img     src="images/banner/buy.gif"></a>
    </body

>

And here is a link to the page: http://riverswest.com/riverswest-site/ambush-jacket.html

The BUY NOW image what you want to click on.


回答1:


The issue is your target="". You don't need it if you're going to be using javascript popup code.

This works fine:

<a href="javascript:newPopup('buy-now/ambush-jacket.html');"><img src="images/banner/buy.gif"></a>


来源:https://stackoverflow.com/questions/18005077/im-trying-to-use-javascript-to-open-a-popup-window-it-works-in-chrome-but-not

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!