Search code examples
jquerywindowhref

Opening an inactive tab in a browser using jQuery


How would you open a new inactive tab in a browser using jQuery, such as using Ctrl+click?


Solution

  • <script type="text/javacript">
    
    $(document).ready(function() {
    
        $("a:not([@href*=])").not("[href^=#]")
            .addClass("external")
            .attr({ target: "_blank" });
        }
    );
    </script>
    

    see if this helps