簡體   English   中英

Firefox window.open(“ about:blank”)沒有打開空白標簽

[英]Firefox window.open(“about:blank”) doesn't open blank tab

我正在嘗試使用注入的javascript代碼打開新窗口。 在Chrome瀏覽器中一切正常,但Firefox不會打開about:blank選項卡,而只有具有相同href和注入腳本的頁面。 我需要此選項卡完全空白,而不是當前選項卡的副本。 這是我正在使用的示例代碼:

var x = window.open('about:blank');
x.document.write('<script>console.log("hello injected world")</script>');

你為什么不做類似window.open('blank.html');事情呢? 並向您的項目中添加一個如下所示的blank.html文件:

<html></html>

嘗試使用空字符串“”而不是“ about:blank”。

var x = window.open("");
x.document.write('<script>console.log("hello injected world")</script>');

它可以在Chrome和Firefox中使用,但取決於您的瀏覽器是否阻止彈出窗口

嘗試使用iframe

var win = window.open();
win.document.write('<iframe width="100%" height="100%"  srcdoc="<html></html>" frameborder="0" allowfullscreen></iframe>')

可能會幫助你

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM