jquery如何在新窗口中打开可单击的div

jquery如何在新窗口中打开可单击的div,jquery,target,Jquery,Target,我想制作一个没有可点击内容的DIV,因为我使用以下jquery代码: <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#whole").click(function () { window.location = $(this).attr

我想制作一个没有可点击内容的DIV,因为我使用以下jquery代码:

<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">

$(document).ready(function() {
$("#whole").click(function () {
    window.location = $(this).attr("href");
    });
});

</script>

$(文档).ready(函数(){
$(“#整”)。单击(函数(){
window.location=$(this.attr(“href”);
});
});
它工作正常,但链接始终在同一窗口中打开。我需要如何更改代码,才能在新窗口中打开div?

您需要

你需要


你可以用下面的方法来做

1) $(文档).ready(函数(){ $(“#divId”)。单击(函数(){ window.open(“openThisPage.html”);//将“openThisPage.html”更改为目标页面 }); });

您可以通过以下方法进行操作

1) $(文档).ready(函数(){ $(“#divId”)。单击(函数(){ window.open(“openThisPage.html”);//将“openThisPage.html”更改为目标页面 }); });
窗口。打开('http://www.yoururl.com');窗口的精确副本。
打开('http://www.yoururl.com');以下内容的精确副本:
window.open($(this).attr("href"))
$("#whole").click(function () {
   window.open($(this).attr("href"), '_blank');
});
$(document).ready(function() {
$("#whole").click(function () {
    window.open("href"); // window.open('https://stackoverflow.com/questions/13452398/jquery-how-to-make-a-clickable-div-open-in-a-new-window');
    });
});
$(document).ready(function() { $("#divId").click(function () { window.open("openThisPage.html"); //Change 'openThisPage.html' to your target page }); });