如何将 div 值传递给 window.open?
我正在尝试将 DIV
传递到新窗口.
I'm trying to pass a DIV
to a new window.
function openWin() {
myWindow=window.open('','','width=200,height=100');
}
HTML
<div id="pass">pass this to the new window</div>
<a href="#" onclick="openWin();">click</a>
谁能帮帮我?
推荐答案
我想你想要这个:
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();
(jsfiddle.net 上的演示)
相关文章