我需要打开多个窗口并获取html内容,然后我要推送或写入新的html页面。这可能吗?
示例:Sample window-click here我们有window1和window2(请参阅提到的图片)。 Window1包含段落1,Window2包含段落2,我需要获得第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>");
是。这个有可能。您可以使用多种方法来执行此操作。 Web爬网和Web爬网技术将在这里为您提供帮助。作为示例,尝试在iframe中加载必要的URL,而无需在其他窗口中打开它们,然后可以轻松访问其DOM元素。然后,只需使用简单的javascript抓取必要的内容,然后将其应用于所需的任何位置即可。