jianghuidong 2009-03-24 15:18
浏览 208
已采纳

DIV的样式CSS显示

<?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="扫&nbsp;描" onclick=scan()>  
  <input type="submit" name="submit" value="提&nbsp;交">
   </form>
</BODY>
</html>

 1。这个方法getpath10()中theResult是一个路径。能打印出来。我这样赋值对么?我得不到呀。

2。我把#换成.行么?用class显示图片有问题呀。


问题补充:
我想在GetImgPath()个方法中得到路径
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 getpath10()
    {
var theResult;
theResult=scanfigner.GetImgPath(1,10);
alert(theResult);
document.getElementById("outerBox").style.cssText="background:url('theResult')";
    }
    alert()能得到路径。,不知道下面那句话对不对?
问题补充:
哈哈 我不会改ID?playfish (资深程序员)我改了,不对。我改错了。
问题补充:
是,前几天实现了。但需求变了。用样式了CSS。
document.getElementById("outerBox").style.cssText="background:url('theResult')";
这样可以么?
  • 写回答

4条回答 默认 最新

  • zhoujuan520 2009-03-24 15:30
    关注

    function getpath()

    {

    var theResult;

    theResult=scanfigner.GetImgPath(1,1);

    alert(theResult);//你看这里是不是弹出了图片的路径
    document.getElementById("preImg").src=theResult; //这样可以
    }

    2.
    #是id选择器,是指定某一个元素的id的css属性
    .是类选择器,表示所有使用这个的元素都用这个样式.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)