javascript 将整个 DOM 复制到新窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4981965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
copy entire DOM to new window
提问by cp.
Hello I have a rendered jsp that does what I want, I need to show it on the second display, how would I copy the entire dom of the current window and create a completely new window? I will later want from the master to further edit that child window and write to it. Any insight greatly appreciated.
您好,我有一个渲染的 jsp 可以满足我的要求,我需要在第二个显示器上显示它,我将如何复制当前窗口的整个 dom 并创建一个全新的窗口?我稍后会希望主人进一步编辑该子窗口并写入它。任何见解都非常感谢。
采纳答案by SpliFF
That would be tricky. You can certainly open a new window and communicate with it but you can't pass DOM objects. You would basically need to convert the generated DOM to a string, pass it across to the new window and then parse it as though it was a document.
那会很棘手。您当然可以打开一个新窗口并与之通信,但您不能传递 DOM 对象。您基本上需要将生成的 DOM 转换为字符串,将其传递到新窗口,然后将其解析为文档。
Like this: Copy Current Webpage Into a New Window
像这样:将当前网页复制到新窗口中

