2017-08-27 102 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/"; 
    } 
    } 
} 
相關問題