Returning false on link click jquery

后端 未结 4 1550
孤街浪徒
孤街浪徒 2021-01-24 22:33

I wish to have a link which opens popup when clicked however I wish it to open a page in a new window if the user doesn\'t have JS enabled.

The following doesn\'t seem t

4条回答
  •  臣服心动
    2021-01-24 23:08

    Also note that event.preventDefault is not present in all browsers and will cause an error in things like IE7 (if memory serves.) To avoid that, use a general if-statement:

    if (e.preventDefault) {  
        e.preventDefault();  
    }  
    e.returnValue = false;
    

    This will prevent the error from being thrown. I believe jQuery uses this approach as well.

提交回复
热议问题