使用自定义HTML而不是URL打开新选项卡

问题描述:

我正在创建一个Greasemonkey脚本,并且想要打开一个新选项卡,该选项卡不会显示URL,但会显示一些HTML作为脚本的一部分。所以基本上我想做这样的事情(这显然不起作用):

I'm making a Greasemonkey script and would like to open a new tab which will not display a URL but some HTML that is part of the script. So basically I want to do something like this (which is obviously not working):

window.open('<html><head></head><body></body></html>');
or
GM_openInTab('<html><head></head><body></body></html>');

欢迎任何提示!

你可以这样做:

var newWindow = window.open();

然后执行

newWindow.document.write(ohai) ;