js打开新窗口链接

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sweet_o/article/details/84870721

1、新窗口中打开

$('#firstLogo').click(function() { window.open("http://www.ibuychem.com",'_top'); });

2、部分超链接在新窗口打开

<script type="text/javascript">
    $(document).ready(function() {   
        $("#div a").attr("target","_blank");
    })
</script>

3、iframe 中的链接只能在iframe 框中打开的问题

在iframe要链接的页面中加上 target="_top" 或 在head中加上 <base target="_top" />

猜你喜欢

转载自blog.csdn.net/sweet_o/article/details/84870721