Not interpret html in iframe but get the information from the html

痴心易碎 提交于 2019-12-25 14:40:14

问题


In order to reduce the time of executing, we decide not to show the table in the iframe as the client cant see it. But we have to copy the contents of the table so as to update the table in the main page (which can be seen by the client).

The principle is that, the iframe shouldn't interpret html, but through a function written by JavaScript, we copy the updated table to the main page. We've thought about commenting the html out in the iframe, but it'll be very complicated as we could not get the element by Document.getElementById(Id). And we'll have to parser the html. Does anybody do similar things?


回答1:


Is the document you're requesting on the same domain as the "main page"? If so, you can request the second document via AJAX and use a regular expression to extract the element from it. This is all done without rendering any additional content to the DOM.

Once you have the table element extracted from the AJAX response, you can add it to the main page DOM.



来源:https://stackoverflow.com/questions/5964201/not-interpret-html-in-iframe-but-get-the-information-from-the-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!