简体   繁体   English

一击带有2个弹出窗口错误

[英]one clicked with 2 pop-up window error

Does anyone know what is it going on? 有人知道这是怎么回事吗? I wrote the following code, so that the user clicked on the code and it will pop-up a window for another page. 我编写了以下代码,以便用户单击该代码,它将弹出另一个页面的窗口。 Somehow, this is always pop-up 2 windows every time when I clicked on the link. 不知何故,每次单击链接时,总是会弹出2个窗口。

<table>
  <tr>
    <td colspan="2" align="center">
        <a id="goLink" style="cursor:pointer">Link</a>
    </td>
  </tr> 
</table>

<script type="text/javascript">

    $("#goLink").click(function () {
        window.open("http://localhost/test.aspx");
    });

</script>

How can I solve this issue? 我该如何解决这个问题?

The only reason that would happen is when you have wired up two click events unknowingly for the anchor tag goLink in your page. 发生这种情况的唯一原因是,您在不知不觉中为页面中的定位标记goLink连接了两个单击事件。 Have you checked that? 你检查了吗?

您的锚点是否具有href属性,如果是这种情况,则可能会发生默认的点击触发,因此您需要使用preventDefault方法停止该操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM