开发者

one clicked with 2 pop-up window error

开发者 https://www.devze.com 2023-02-20 12:26 出处:网络
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

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.

<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. Have you checked that?


does your anchor have a href attribute to if that is the case there might be a default click firing and you need to stop that using preventDefault method

0

精彩评论

暂无评论...
验证码 换一张
取 消