javascript based tag ( type ='file'
) created
and add one attribute in that tag
that attribute name onchange
, i will assign alert
But alert is not come when choice the new file in internet explore.
choicefile.setAttribute("onChange", "alert('test')");
Try with this:
try onclick="javascript:alert('test');" instead of onchange. Old ie versions and compatibility modes don't support onchange very well.
Your code seems correct. Something particular with IE is, if you put higher security level, you need to allow scripts and activeX content when you load the website.
You can do two ways,
1.. Using HTML, add
onchange
event inlineDemo: http://jsfiddle.net/CS3xJ/1/
2.. Using JS,
Demo: http://jsfiddle.net/CS3xJ/2/
There is actually a difference between
setAttribute
andattachEvent
. Here is an example usingattachEvent
(for IE) andaddEventListener
(standards) to add the event.Also, not that the event handler is a function, rather than a string: