【发布时间】:2021-02-13 00:23:22
【问题描述】:
我需要打开多个窗口并获取html内容,然后我要推送或写入 新的 html 页面。这可能吗?
示例:Sample window-click here 我们有 window1 和 window2 (见提到的图片)。 Window1 包含paragraph1,Window2 包含paragraph2, 我需要得到这第1和2段,写入window3
我有编写新窗口的代码,请建议或帮助实现我的要求?
我的代码:
var url = document.getElementById('ifrmDivisionPage').src;
var tabOrWindow = window.open(url, '_blank');
tabOrWindow.document.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" );
tabOrWindow.document.write( "<html>" );
tabOrWindow.document.write( "<head>" );
tabOrWindow.document.write( "<meta charset='utf-8'>" );
tabOrWindow.document.write("</head><body>");
tabOrWindow.document.write($("#ifrmDivisionPage").contents().find("body").html());
tabOrWindow.document.write("</body>");
tabOrWindow.document.write("</html>");
【问题讨论】:
-
为什么不使用 XHR (ajax)?
-
你能分享任何示例代码示例吗?
标签: javascript jquery html dom