如何在Firefox中扩展document.getElementsBy *() [英] how to extend document.getElementsBy*() in Firefox
问题描述
我想将一个方法添加(原型)到由 document.getElementsByName()(和相关的,即NodeList和HTMLCollection)返回的节点列表中。
遗憾的是,NodeList和HTMLCollection接口似乎都不是Firefox中的原型。 (NodeList适用于Safari和Opera,不知道IE浏览器)
有没有人知道如何解决这个问题?
注意:这个问题已经讨论过了,虽然我没有找到解决这个问题的方法。 (除了原型到Object接口之外)。
我认为这不可行。创建一个完成工作的函数或使用nodelist创建自己的对象,然后再扩展它。
你的意思是用 document.getElementsBy *()代替我自己的功能(种类)?
可能你可以忍受这样的事情:
展开 | 选择 | Wrap | 行号
I want to add (prototype) a method to the node list returned by document.getElementsByName() (and related, i.e. NodeList resp. HTMLCollection).
unfortunately, neither the NodeList nor the HTMLCollection interface seem to be prototypable in Firefox. (NodeList works in Safari & Opera, don''t know about IE)
has anyone of you an idea how to solve this?
note: this matter has already been discussed, though I didn''t find any solution to this problem. (beside prototyping into Object interface).解决方案I don''t think this is possible. Either create a function which does the job or create your own object with the nodelist and then extend that instead.
you mean substituting document.getElementsBy*() with my own function (kind of)?
may be you could live with something like that:
Expand|Select|Wrap|Line Numbers
这篇关于如何在Firefox中扩展document.getElementsBy *()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
登录 关闭
![](https://huajiakeji.com/Content/Images/qrydx.jpg)