[英]Firefox window.open(“about:blank”) doesn't open blank tab
I'm trying to open new window with injected javascript code. 我正在尝试使用注入的javascript代码打开新窗口。 Everything works fine in Chrome, but Firefox doesn't open about:blank tab, but only a page with same href and injected script.
在Chrome浏览器中一切正常,但Firefox不会打开about:blank选项卡,而只有具有相同href和注入脚本的页面。 I need this tab to be perfectly blank, not a copy of current tab.
我需要此选项卡完全空白,而不是当前选项卡的副本。 Here is my example code that i'm using:
这是我正在使用的示例代码:
var x = window.open('about:blank');
x.document.write('<script>console.log("hello injected world")</script>');
why don't you do something like window.open('blank.html');
你为什么不做类似
window.open('blank.html');
事情呢? and add a blank.html
file to your project that looks like this for example: 并向您的项目中添加一个如下所示的
blank.html
文件:
<html></html>
Try with empty string "" instead of "about:blank". 尝试使用空字符串“”而不是“ about:blank”。
var x = window.open("");
x.document.write('<script>console.log("hello injected world")</script>');
It will work in both Chrome and Firefox, but it depends your browser is not blocking pop ups 它可以在Chrome和Firefox中使用,但取决于您的浏览器是否阻止弹出窗口
Try using Iframe 尝试使用iframe
var win = window.open();
win.document.write('<iframe width="100%" height="100%" srcdoc="<html></html>" frameborder="0" allowfullscreen></iframe>')
Might help you out 可能会帮助你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.