Aja*_*jax 0 html jquery dom object
我在jsfiddle上有这个代码.
HTML:
<object type="text/html" data="http://www.w3.org/" style="width:100%; height:100%;position: absolute;bottom: 0;"></object>
Run Code Online (Sandbox Code Playgroud)
JS:
console.log($('object').find('*').length);
Run Code Online (Sandbox Code Playgroud)
在标签中有一个奇怪的#document标签,我找不到任何标签,控制台说,有零元素.
我如何从DOM中读取<object>?什么是#document <object>?
不要使用<object>元素来加载HTML文档.使用<iframe>s代替 - 支持和API更好.
然后你可以使用
var frame_contents = $('iframe').contents();
console.log($(frame_contents).find("*").length);
Run Code Online (Sandbox Code Playgroud)
...如果您从其他来源加载文档,则受制于通常的跨源安全限制.