javascript - 如何在新选项卡中打开链接而不在新选项卡中看到 URL?
问题描述
我一直在尝试很多事情来完成这项工作,但还没有。如何在新标签页中打开网站,但不显示正在使用的 URL?我从这个网站得到了这个想法。新标签 URL 显示为about:blank
。但是,我无法让它工作。我是 Javascript 新手,所以放轻松!谢谢!!!
这是我尝试过的:
function NewTab() {
window.open(
"https://www.mywebsite.com", "_blank");
}
解决方案
在浏览了网站之后,我能够找到打开一个新选项卡的 JS,“而不”向用户公开 URL:
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>
推荐阅读
- go - 如何处理 ssh.StdoutPipe() 的特定字符
- c# - 如何使用 C# 从具有 TextValue 格式元素的 xml 中的多个节点读取值
- python - 有没有办法在没有唯一 ID 的 Selenium 网页上选择一个项目?
- google-apps-script - 谷歌应用程序脚本异步等待表格 api
- r - 根据另一个向量中的值在 r 中创建逻辑向量
- hl7-fhir - 为 FHIR 设置 SMART 应用程序并利用现有资源
- reactjs - 如何根据单击的单选按钮显示和隐藏文本字段类型编号?
- python-3.x - valueError:在使用 google oauth 客户端和同时请求时对关闭的文件进行 I/O 操作
- sqlalchemy - 在 SQLAlchemy 中更新现有子对象并将新子对象附加到父对象的有效方法是什么?
- react-native - VictoryLabel 坐标与 VictoryChart 域不匹配