2017-08-27 98 views
0
function myFunction() { 
var x = document.querySelectorAll("a"); 
var i; 
for (i = 0; i < x.length; i++) { 
    window.location.href = "https://google.com/"; 
} 
} 

如何让此脚本仅在桌面上工作?Popunder/Tabunder脚本不适用于手机或仅适用于台式机

或让它在移动设备上工作。

该脚本将当前标签重新加载到谷歌,并打开另一个标签与测试链接。 测试链接

我希望有人能帮助我。最好没有jQuery。

回答

0

你可能意味着

function myFunction() { 
    var x = document.querySelectorAll("a"); 
    for (var i = 0; i < x.length; i++) { 
    x[i].onclick=function() { 
     window.open("https://google.com/","blank"); 
    } 
    } 
} 

function myFunction() { 
    var x = document.querySelectorAll("a"); 
    for (var i = 0; i < x.length; i++) { 
    x[i].onclick=function() { 
     window.open(this.href,"_blank"); 
     location="https://google.com/"; 
    } 
    } 
} 
相关问题