Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在新窗口中打开链接,html表上的javascript_Jquery_Html - Fatal编程技术网

Jquery 在新窗口中打开链接,html表上的javascript

Jquery 在新窗口中打开链接,html表上的javascript,jquery,html,Jquery,Html,我的表中的链接有问题 我使用: <script type="text/javascript"> jQuery(document).ready(function($) { $(".clickable-row").click(function() { window.document.location = $(this).data("href"); }); }); </script> 在: 不起作用

我的表中的链接有问题

我使用:

<script type="text/javascript">
    jQuery(document).ready(function($) {
        $(".clickable-row").click(function() {
            window.document.location = $(this).data("href");
        });
    });
</script>
在:


不起作用

有什么想法吗?

窗口。打开('href')

窗口位置设置当前窗口的位置。

窗口。打开('href')


窗口位置设置当前窗口的位置。

使用
Window.open=”怎么样http://....“,”target=“\u blank”)


使用
窗口如何。打开=”http://....“,”target=“\u blank”)

你可以像这样做:

jQuery(document).ready(function($) {
    $(".clickable-row").click(function() {
        if(this.hasAttribute("target")){
            window.open($(this).data("href"),$(this).data("target"));
        }
        else{
            window.document.location = $(this).data("href");
        }
    });
});
检查

编辑:
以下是您评论的解决方案:

  jQuery(document).ready(function($) {
    $(".clickable-row").click(function() {
        if(this.getAttribute("href").substr(this.getAttribute("href").length - 3)=== "###"){
            window.open(this.getAttribute("href").substring(0, this.getAttribute("href").length-3),"_blank");
        }
        else{
            window.document.location = $(this).data("href");
        }
    });
});
你可以这样做:

jQuery(document).ready(function($) {
    $(".clickable-row").click(function() {
        if(this.hasAttribute("target")){
            window.open($(this).data("href"),$(this).data("target"));
        }
        else{
            window.document.location = $(this).data("href");
        }
    });
});
检查

编辑:
以下是您评论的解决方案:

  jQuery(document).ready(function($) {
    $(".clickable-row").click(function() {
        if(this.getAttribute("href").substr(this.getAttribute("href").length - 3)=== "###"){
            window.open(this.getAttribute("href").substring(0, this.getAttribute("href").length-3),"_blank");
        }
        else{
            window.document.location = $(this).data("href");
        }
    });
});

我通过添加两个类和两个函数修复了该问题:

<script type="text/javascript">
    jQuery(document).ready(function($) {
    $(".istiprozor").click(function() {
        window.document.location = $(this).data("href");
    });
$(".noviprozor").click(function() {
       window.open($(this).data("href"),$(this).data("target"));
    });
});
    </script>

jQuery(文档).ready(函数($){
$(“.istiprozor”)。单击(函数(){
window.document.location=$(this.data(“href”);
});
$(“.noviprozor”)。单击(函数(){
window.open($(this.data(“href”),$(this.data(“target”));
});
});

我通过添加两个类和两个函数解决了这个问题:

<script type="text/javascript">
    jQuery(document).ready(function($) {
    $(".istiprozor").click(function() {
        window.document.location = $(this).data("href");
    });
$(".noviprozor").click(function() {
       window.open($(this).data("href"),$(this).data("target"));
    });
});
    </script>

jQuery(文档).ready(函数($){
$(“.istiprozor”)。单击(函数(){
window.document.location=$(this.data(“href”);
});
$(“.noviprozor”)。单击(函数(){
window.open($(this.data(“href”),$(this.data(“target”));
});
});


在谷歌搜索
opennewwindowjavascript
或类似术语有多难?这里提出的问题应该表明至少已经尝试了一些研究工作。您的代码应该是
window.open($(this.data)(“href”)opennewwindowjavascript
或类似的术语有多难?这里提出的问题应该表明至少已经尝试了一些研究工作。您的代码应该是
window.open($(this.data)(“href”)