<?xml version="1.0" encoding="gb2312"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!--<meta http-equiv="refresh" content="10"> --> <title>活体扫描</title> </head> <BODY bgcolor="#66CCFF"> <style type="text/css"> #outerBox{ width:90px; height:50px; border:1px black solid; text-align:center; font-size:20px; color:red; background-color:#66CCFF; line-height:90px; float: left; margin-right:20px; margin-bottom:20px; /* 下间距 */ } </style> <object CLASSID="CLSID:686AC84F-27DE-49F9-92AD-2CDA68C419F2" WIDTH=642 HEIGHT=690 CODEBASE="file:///C:/bag/scan.CAB" ID="scanfigner"></object> <script type="text/javascript" language="javascript"> //得到图片路径 function getpath() { var theResult; theResult=scanfigner.GetImgPath(1,1); document.getElementById("preImg").src=theResult; } function getpath10() { var theResult; theResult=scanfigner.GetImgPath(1,10); var myImg = document.getElementById("outerBox"); myImg.style.cssText="background:url('theResult')"; } //执行扫描 获取指纹 function scan() { scanfigner.ExeScan(1,1); } //通过写路径来显示图片 function clickdiv(){ var myImg = document.getElementById("outerBox"); myImg.style.cssText="background:url('rr.jpg')"; } </script> <form action="" method="post"> <div id="outerBox" onclick="clickdiv();">右拇</div> <div id="outerBox">右食</div> <div id="outerBox">右中</div> <div id="outerBox">右环</div> <div id="outerBox">右小</div> <div style="clear:both;"></div> <div id="outerBox">左拇</div> <div id="outerBox">左食</div> <div id="outerBox">左中</div> <div id="outerBox">左环</div> <div id="outerBox" onclick="getpath10();">左小</div> <input type="button" name="submit" value="扫 描" onclick=scan()> <input type="submit" name="submit" value="提 交"> </form> </BODY> </html>
1。这个方法getpath10()中theResult是一个路径。能打印出来。我这样赋值对么?我得不到呀。
2。我把#换成.行么?用class显示图片有问题呀。
function getpath()
{
var theResult;
theResult=scanfigner.GetImgPath(1,1);
alert(theResult);//你看这里是不是弹出了图片的路径
document.getElementById("preImg").src=theResult; //这样可以
}
2.
#是id选择器,是指定某一个元素的id的css属性
.是类选择器,表示所有使用这个的元素都用这个样式.
[url]http://www.iteye.com/problems/13235[/url]
我说这个代码好眼熟啊..原来前几天刚看过一个一样的问题...还是你呀
myImg.style.cssText="background:url('theResult')";
改成
myImg.style.cssText="background:url("+theResult+")";
试试吧.
不过你的一堆id没改过来..还是会有问题的..
theResult 你弹出来值了么?
myImg.style.cssText="background:url("+theResult+")";
改过了吗....?这样不行?