gpt4 book ai didi

javascript - 在包含 dom 的弹出窗口中克隆页面

转载 作者:行者123 更新时间:2023-11-28 02:47:23 24 4
gpt4 key购买 nike

是否可以在新的弹出窗口中克隆页面、JavaScript 和元素?

我想创建一个像内容框一样使用的 div 弹出窗口,所有内容都在 javascript 中加载

类似的东西

var popup=window.open('', '_blank');
popup.document = this.document;
popup.document.close();

感谢您的帮助

最佳答案

我不知道您为什么要打开当前窗口的副本然后将其关闭...但是您可以这样做:

if(window.name != 'mypopup') {
window.open(document.location.href,'mypopup');
} else {
window.onload = self.close();
}

** 请注意窗口名称检查。没有它,您将只会得到窗口打开的无尽进度...

<小时/>
<script type="text/javascript">

function popdiv(thediv) {
popwidth = thediv.width;
popheight = thediv.height;
popargs = 'width=' + popwidth + ', height=' + popheight;

popcontents = thediv.innerHTML;
thewindow = window.open('#', 'mypopup', popargs);
thedocument = thewindow.document.open();
thedocument.write = popcontents;
thedocument.close();

}

</script>

<div onclick="popdiv(this);">
Hello,<br />is it possible to clone an page, javascript and elements in a new popup?<br />
<br />I want to create a popup of a div used like a box of content, all is loaded in javascript <br />
Thanks for your help</div>

关于javascript - 在包含 dom 的弹出窗口中克隆页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4591099/

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