How to simulate target=“_blank” in JavaScript

前端 未结 7 1681
旧巷少年郎
旧巷少年郎 2020-12-02 08:05

When a user clicks on a link, I need to update a field in a database and then open the requested link in a new window. The update is no problem, but I don\'t know how to op

相关标签:
7条回答
  • 2020-12-02 08:33

    This is how I do it with jQuery. I have a class for each link that I want to be opened in new window.

    $(function(){
    
        $(".external").click(function(e) {
            e.preventDefault();
            window.open(this.href);
        });
    });
    
    0 讨论(0)
提交回复
热议问题