I cannot figure how to get my JS to open the URL in another tab.
Here’s the script
function viewSource(){
var webcache = "http://webcache.googleusercontent.com/search?q=cache:";
var request = "&prmd=ivn&strip=0&vwsrc=1";
var url = window.prompt("Enter valid URL");
window.location.href = webcache + url + request;
}
viewSource();
I tried adding ’_blank’
in the code, but I couldn’t figure where to place it.
Maybe it can only be achieved with window.open(url)
?
Edit: I forgot to mention that it must be suitable for Safari browsers, see window.open(url, '_blank'); not working on iMac/Safari.