<img id="picture" class="x" src="" />id="picture" id使这个啊.. 怎么 你用.getElementById("pic"); 这pic个去取呢?var pic = document.getElementById("pic");
pic.src = filePath;
pic.src = filePath;
解决方案 »
- 前台如何获取后台声明的二维数组
- 日期选择器
- 随机迷宫生成算法JavaScript
- jquery 查找子元素
- htm页面父窗口页面表单中textarea的值向子窗口列表传递值的问题
- [前辈]如何得到元素右侧的坐标?本人有结贴的好习惯,在线等
- 在页面被遮住的情况下如何对其聚焦?
- ***请教了:下面的一段代码中的onchang...与<optinon>.../<option>的含义?***谢谢!
- 请问怎样才能达到下面的效果?
- 新手求助:为什么在火狐和谷歌删除节点要点两次按钮才能删除
- |zyciis| 为什么我的document.getElementsByName("liSeries");取不到对像 谢谢 急
- 关于用window.history.go后退次数好像只有6次?
pic.src = filePath; 而且保证在这个页面中没有id="picture"的控件唯一!你可以用alert输出一下pic是否有值,以确定问题出在filePath还是其他方面。可以在详细描述一下你的问题吗?
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title>Page1</title>
<script language=javascript>
function playButton(){
var pic = document.getElementById("picture");
pic.src = "http://www.baidu.com/img/baidu.gif";
}
</script>
</head><body>
<body>
<div id="image">
<img id="picture" class="x" src=""/>
<input id="playButton" type="button" onclick="playButton()" value="Play"/>
</div>
</body>
</body></html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title>Page1</title>
<script language=javascript>
function playButton(){
var pic = document.getElementById("picture");
pic.src = "http://www.baidu.com/img/baidu.gif";
}
</script>
</head><body>
<body>
<div id="image">
<img id="picture" class="x" src=""/>
<input id="playButton" type="button" onclick="playButton()" value="Play"/>
</div>
</body>
</body></html>
试了一下,这样可以啊
都是唯一的~~
最后我把window.onload写在html里面,把<script></script>里的window.onload = init();注释掉~~居然可以了~~
<body>
<div id="image">
<img id="pic" class="x" src="" />
<input id="backButton" type="button" onclick="backButton();" value="Back"/>
<input id="returnButton" type="button" onclick="returnButton();" value="Return"/>
<input id="nextButton" type="button" onclick="nextButton();" value="Next"/>
<input id="playButton" type="button" onclick="playButton();" value="Play"/>
<input id="stopButton" type="button" onclick="stopButton();" value="Stop"/>
<script>
window.onload = init();
</script>
</div>
</body>各位能告诉我为什么?
是不是运行的时候<img>比window.onload = init()后解释本?
<td class="red_sign">*</td>
<td class="table_info">
<img src="" width="130px" height="142px" alt="相片" id="pic"/> <br/>
<c:if test="${sysphoto==null}">
<input type="file" id="upfile" class="i_button" value="上传图片" name="upFile.upload" onchange="check_imageProperty(this);"/>
js代码: var regu = "^[ ]+$";
var re = new RegExp(regu);
var FileObj;
function check_imageProperty(obj){
FileObj=obj;
var ImgObj=new Image();//建立一个图像对象
var AllowExt=".jpg|.gif|";
if(obj.value==""){
document.getElementById("checkimage").style.display="block";
document.getElementById("checkimage").innerHTML="<font color='red'>请上传您公司的图片!</font>";
return false;
}
else{
var FileExt=obj.value.substr(obj.value.lastIndexOf(".")).toLowerCase();
if(AllowExt!=0&&AllowExt.indexOf(FileExt+"|")==-1){ //判断文件类型是否允许上传
var ErrMsg="\n该文件类型不允许上传!请上传"+AllowExt+"类型的文件,当前文件类型为"+FileExt;
document.getElementById("checkimage").style.display="block";
document.getElementById("checkimage").innerHTML="<font color='red'>"+ErrMsg+"</font>";
return false;
}
var photoname= document.getElementById("photoname").value;
if(photoname.length==0||photoname==""||re.test(photoname)){
var name1=obj.value.split('\\');
var name2=name1[name1.length-1].split('.');
var name3=name2[0];
var name4;
if(name3.replace(/[^\x00-\xff]/g,"**").length>15){
name4=name3.substring(0,14);
} else{
name4=name3;
}
document.getElementById("photoname").value=name4;
}
document.getElementById('pic').src=obj.value; ImgObj=document.getElementById("pic");
if(ImgObj.readyState!="complete"){
setTimeout("check_imageProperty(FileObj)",500);
return false;
}
alert("jixu");
var ImgFileSize=Math.round(ImgObj.fileSize/1024*100)/100;
alert(ImgFileSize);
if(ImgFileSize>200){
var ErrMsg="\n上传的图片超过限制!请上传大小200k以内的文件,当前文件大小为"+ImgFileSize+"k";
document.getElementById("checkimage").style.display="block";
document.getElementById("checkimage").innerHTML="<font color='red'>"+ErrMsg+"</font>";
return false;
}
document.getElementById("checkimage").style.display = "none";
return true;
}
}执行到红色的那行就不执行了 在ie6上是可以的 为什么到ie7就不行了呢 各位大侠 帮帮忙了...