页面在IE6中没问题,放在HTML文件中双击浏览也没问题,但通过LOCALHOST访问,图片就显示不出来,IE8也是,请高手帮忙解决~~~代码如下:
<input id="pic" onchange="changePic()" onmousedown="picDown()" type="file" />
<img id="bg_img" src="" height="100%" width="100%" />
function changePic()
{
var myfile=document.getElementById("pic");
myfile.select();
document.getElementById("bg_img").src =document.selection.createRange().text;;
document.getElementById("watchpic").style.display = "block";
}
注:watchpic是bg_img的父层
<input id="pic" onchange="changePic()" onmousedown="picDown()" type="file" />
<img id="bg_img" src="" height="100%" width="100%" />
function changePic()
{
var myfile=document.getElementById("pic");
myfile.select();
document.getElementById("bg_img").src =document.selection.createRange().text;;
document.getElementById("watchpic").style.display = "block";
}
注:watchpic是bg_img的父层
<img id="bg_img" src="" height="100%" width="100%" />
这样既可,我在本地试了,IE8可以用
是不是要加端口号啊。
用滤镜:请Google:AlphaImageLoader 介绍。
用背景:obj.style.backgroundImage = "url('"+inputFile.value+"')";