搜索里面的iframe一个特定的标记,并创建另一个IFRAME
问题描述:
我有以下代码:搜索里面的iframe一个特定的标记,并创建另一个IFRAME
<FORM target="frame" onsubmit="document.getElementById('frame').style.display = 'block';" method="post" action="http://www.example.com/index.html">
<input type="text" autocomplete="off" value="" name="search-field" id="header-search-field">
<button type="submit">Search</button></FORM>
<iframe width="700" height="700" id="frame" name="frame" style="display: none;"></iframe>
iframe中正确显示刚提交表单。现在我必须创建第二个iframe,它在之前加载的内容中搜索特定的标签,并且仅在发现时才显示。 我必须寻找一个特定的标签:
<table id="item_specification" cellspacing="0" cellpadding="0"> with all the content inside </table>
,仅显示表ID里面的内容(有桌子太)
答
,如果你不打破跨起源策略,你可以访问iframe的文档这种方式:
document.getElementById('header-search-field').contentDocument
你能解释一下吗? Iframe和表单在不同的域中。 – 2014-09-03 05:35:20