gpt4 book ai didi

javascript - 如何将div值传递给window.open?

转载 作者:行者123 更新时间:2023-12-02 14:45:48 25 4
gpt4 key购买 nike

我正在尝试将 DIV 传递到新窗口。

JavaScript

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();

( Demo at jsfiddle.net )

关于javascript - 如何将div值传递给window.open?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12311268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com