我有一个代码,可以在旧标签和新标签中显示隐藏的内容。但我想在新标签页而不是旧标签页中显示隐藏的div内容。你能帮我一下吗 HTML:
<div id="pass" hidden>pass this to the new window</div>
<a href="#" onclick="openWin()">click</a>
Java脚本:
function openWin() {
var x = document.getElementById("pass");
x.style.display = "block";
var divText = document.getElementById("pass").outerHTML;
var myWindow = window.open('', '', 'width=200,height=100');
var doc = myWindow.document;
doc.open();
doc.write(divText);
doc.close();
}