带有警报的onchange不起作用,即 [英] onchange with alert not working in ie

查看:85
本文介绍了带有警报的onchange不起作用,即的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于javascript的标记(type ='file')已创建

javascript based tag ( type ='file' ) created

并在该标签中添加一个属性

and add one attribute in that tag

该属性名称onchange,我将分配警报

that attribute name onchange, i will assign alert

但是在Internet Explorer中选择新文件时不会发出警报.

choicefile.setAttribute("onChange", "alert('test')");

推荐答案

您可以采取两种方式,

1 ..使用HTML,内联添加onchange事件

1.. Using HTML, add onchange event inline

<input type="file" id="file_select" name="file_select" value="" onchange="alert('File selected')" />

演示: http://jsfiddle.net/CS3xJ/1/

2 ..使用JS,

  choicefile.onchange = function(){
     alert('File selected')
  }

演示: http://jsfiddle.net/CS3xJ/2/

这篇关于带有警报的onchange不起作用,即的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆