问题描述
RE:
上述问题处理在进行文件选择之后,让'change'事件在浏览器之间始终保持一致。这一点已经解决了,例如的示例, p>
我的情况是不一样的。看来这个问题在另一个上下文中重演了它的丑陋的头。
基于设计约束,我必须使用非文件输入元素('a'触发文件输入元素上的点击事件。远离我的测试,当以这种方式选择文件时,文件输入看起来不能触发更改通知。
请看看的示例p>
测试环境:
Windows Server 2008 R2
- Chrome 7.0.517.44 - PASS
- Firefox 3.6.9 - FAIL
- IE 8.0.7600.16385 64位 - FAIL
Windows XP Pro(2002 - SP3)
- Chrome 8.0.552.28 beta - PASS
- Firefox 3.5.14 - FAIL(甚至不会触发文件选择器)
- IE 8.0.6001.18702 - FAIL
MSIE使用 - 事件,例如丰富:
由于jQuery不支持此事件,您必须在不使用jquery(内联或使用attachEvent))的情况下进行分配。
在其他浏览器中,尝试使用突变 - 事件,也许他们会在那里工作。请参阅昨天关于突变事件的相关主题,以了解他们的工作原理:
RE:
- Jquery: change event to input file on IE
- Any alternative to jQuery change() to detect when user selects new file via dialog box in IE8?
The above questions dealt with getting the 'change' event to fire consistently across browsers after a file selection has been made. This is has been resolved as evidenced by the example at http://jsfiddle.net/7wR2L/
My situation is a tad different. It seems this issue rears its ugly head in another context.
Based on design constraints, I have to use a non-file-input element ('a' tag) to trigger the "click" event on the file input element. So far from my tests, it looks like the file input is unable to fire a "change" notification when a file is selected in this way.
Please take a look at the example at http://jsfiddle.net/rudylattae/7wR2L/8/
Test environment(s):
Windows Server 2008 R2
- Chrome 7.0.517.44 - PASS
- Firefox 3.6.9 - FAIL
- IE 8.0.7600.16385 64bit - FAIL
Windows XP Pro (2002 - SP3)
- Chrome 8.0.552.28 beta - PASS
- Firefox 3.5.14 - FAIL (does not even trigger the file selector)
- IE 8.0.6001.18702 - FAIL
With MSIE use the onpropertychange-Event, example: http://jsfiddle.net/7wR2L/14/
As jQuery does'nt support this event you have to assign it without jquery(inline or use attachEvent )
In other browsers try using mutation-events, maybe they'll work there. See a related topic on mutation-events from yesterday, to have a little example how they work: How to capture change on page title from a firefox extension
这篇关于jQuery:“更改”如果文件选择由文件输入以外的元素触发,文件输入元素上的事件不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!