专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > vbScript

为什么这段脚本失效?该如何解决

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
为什么这段脚本失效?
下述代码中 "document.formfoo.txtHardDiskSN.value   =   hex(f.serialnumber)
"没有成功的执行,该文本框没有成功显示硬盘序列号,但 "document.write(hex(f.serialnumber)) "却能够成功打印这个硬盘序列号。何解?

<html>  
  <head>
    <script   language= "vbscript ">        
    set       fs       =       CreateObject( "scripting.filesystemobject ")  
    set       f   =   fs.GetDrive( "c: ")  
    document.write(hex(f.serialnumber))
    document.formfoo.txtHardDiskSN.value   =   hex(f.serialnumber)
    </script>
    </head>  
    <body>
    <form   name= "formfoo "> <input   value= "aaa "   name= "txtHardDiskSN "   type= "text "> </input>   </FORM> </BODY>
    </html>

------解决方案--------------------
因为你的脚本写在了控件之前,脚本执行的时候控件还没加载。你把脚本写到控件后就可以了:
<html>
<head>
</head>
<body>
<form name= "formfoo "> <input value= "aaa " name= "txtHardDiskSN " type= "text "> </input> </FORM> </BODY>
<script language= "vbscript ">
set fs = CreateObject( "scripting.filesystemobject ")
set f = fs.GetDrive( "c: ")
document.write(hex(f.serialnumber))
document.all.formfoo.txtHardDiskSN.value = hex(f.serialnumber)
</script>
</html>
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: