JS函数调用问题(比较简单格式问题)
<input type= "file " name= "FILENAME " onChange= "setTimeout( 'checkimage(newImg) ',500) " style= "width:500; height:25 "> 这里面的newImg 是我想给checkimage()函数传的参数,格式应该怎么写啊,这样写是错的。
------解决方案-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
<SCRIPT LANGUAGE= "JavaScript ">
<!--
newImg = "aaa.jpg ";
function checkimage(img) {
alert(img);
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<input type= "file " name= "FILENAME " onChange= "setTimeout(checkimage(newImg),500) " style= "width:500; height:25 ">
</BODY>
</HTML>
------解决方案--------------------给个公共变量存放你想传递的参数 调用前先修改变量的值
<input type= "file " name= "FILENAME " onChange= "timeoutArg=newImg;setTimeout( 'checkimage() ',500) " style= "width:500; height:25 ">
<script>
var timeoutArg = ....;
...
...
...
var checkimage = function()
{
var xxx = timeoutArg;
}
</script>
------解决方案--------------------这个关键要看 newImg 有没有定义了...
setTimeout 是可以传参的....