使用 jquery 访问嵌入对象在 Firefox 3.6 中不起作用
我的插件中的这段代码过去工作得很好:
jQuery('#embedded_obj', context).get(0).getVersion();
而 html...
<object id="embedded_obj" type="application/x-versionchecker-1.0.0.1"></object>
基本上试图从嵌入对象中获取属性。但看起来 get(0) 返回的是 html 对象而不是实际的嵌入对象。
例如,如果我这样做:
var launcher = jQuery('#embedded_obj', context).get(0);
for(prop in launcher){
alert(prop + ': ' + launcher[prop]);
}
...它会发出诸如“getElementByNode”、“scrollWidth”、“clientLeft”、“clientTop”等的警报。
同样,这在 Firefox 3.6 之前有效。还有其他人看过这个或有任何想法/建议吗?
谢谢!
this code in my plugin used to work just fine:
jQuery('#embedded_obj', context).get(0).getVersion();
and the html...
<object id="embedded_obj" type="application/x-versionchecker-1.0.0.1"></object>
Basically trying to get the properties from an embedded object. But it looks like get(0) is returning an html object instead of the actual embedded object.
For example, if I do:
var launcher = jQuery('#embedded_obj', context).get(0);
for(prop in launcher){
alert(prop + ': ' + launcher[prop]);
}
... it alerts things like "getElementByNode," "scrollWidth," "clientLeft," "clientTop" etc.
Again this worked before Firefox 3.6. Has anyone else seen this or have any ideas/suggestions?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你确定它之前有效吗? jQuery(..).get(..) 总是返回一个 DOM 对象(在本例中为
So 这样的 语法负责 HTML DOM 元素和实际嵌入对象之间链接的构造函数?
如果是这样,您是否使用一个小
test.html
文件对其进行检查,并使用两个浏览器打开该文件以验证行为差异?编辑:没关系,在我用谷歌搜索并偶然发现 http://forum.jquery.com/topic/jquery -object-get-0-is-not-a-dom-element-in-ff-but-is-in-safari-is-this-a-bug
are you sure it worked before? jQuery(..).get(..) always returns a DOM object (in this case the
<object>
element), so are you sure you didn't use a syntax likeSo with a constructor that takes care of the link between the HTML DOM element and the actual embedded object?
If so, did you check it with a small
test.html
file or so and open this with the two browsers to verify the difference in behaviour?Edit: nevermind, there is really something strange going on indeed with the object-tag after I googled about it and stumbled on http://forum.jquery.com/topic/jquery-object-get-0-is-not-a-dom-element-in-ff-but-is-in-safari-is-this-a-bug