I've been trying many things to make this work but nothing has yet. How can I open a website in a new tab and have it not show the URL being used? I got this idea from this website. The new tabs URL shows up as about:blank
. However, I've not been able to get it to work. I'm new to Javascript so go easy on me! Thanks!!!
This is what I've tried:
function NewTab() {
window.open(
"https://www.mywebsite.com", "_blank");
}
CodePudding user response:
After digging through the website I was able to find the JS that opens a new tab "without" exposing the URL to the user:
var urlObj = new window.URL(window.location.href);
var url = "https://tam-shellshock.franklinformulas.com"
if (url) {
var win;
document.querySelector('a').onclick = function() {
if (win) {
win.focus();
} else {
win = window.open();
win.document.body.style.margin = '0';
win.document.body.style.height = '100vh';
var iframe = win.document.createElement('iframe');
iframe.style.border = 'none';
iframe.style.width = '100%';
iframe.style.height = '100%';
iframe.style.margin = '0';
iframe.src = url;
win.document.body.appendChild(iframe);
}
};
}
<a>Press here</a>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>