以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何让网页显示时,光标默认在sn控件处闪烁?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=131132)

--  作者:ycwk
--  发布时间:2019/2/18 11:44:00
--  如何让网页显示时,光标默认在sn控件处闪烁?
如何让打开这个网页时,光标就在  sn  字段闪烁  


Dim e As RequestEventArgs = args(0)
Dim wb As New weui
\'wb.DeleteCookie("SN")   \'打开或跳转此页面则清除cookies  中的SN

If e.Cookies.ContainsKey("username") Or e.Cookies.ContainsKey("password")  Then   \'如果cookie里面有 username 和 password字段
   \' wb.AddForm("","form1","CheckPd.htm").Attribute=""       \'checkpd.htm 是接收结果的页面
     wb.AddForm("","form1","CheckPd.htm")     \'.Attribute=""        \' 由CheckPd接收提交的数据


     With wb.AddInputGroup("form1","ipg1","请扫描设备标签上的二维码")
       \' .AddInput("AssetNumber","资产编号","Text")       \'前一个"AssetNumber"是ID,后一个"资产编号"是标题 
        \'.AddInput("AssetNumber","资产编号","Text").Attribute="" 
        \' .AddInput("AssetNumber","资产编号","Text").Attribute="""
         \'.AddInput("AssetNumber","资产编号","Text").Attribute="""
         .AddInput("SN","SN","Text").Attribute="""
         .AddHidenValue("test","test")    \'为了避免一扫描就跳转,添加的干扰代码
     End With


     With wb.AddButtonGroup("form1","btg1",True)   \'显示  待用户扫描的界面
        .Add("btnOK","确定","button").Attribute=""         \'button千万不能写成submit,否则就会造成数据提交两遍
        \'.Add("btnOK","继续","./CheckPd.htm?AssetNumber=" & "172.16.5.1" )   
        \'.Add("btnExit","退出登录","./exit.htm" )        \'退出盘点按钮
        .Add("btn1", "退出登录", "button","./exit.htm")    \'返回原页面
     End With



    \'当扫描到没有收录的二维码时,给出不存在的提示
     With wb.AddDialog("","dlg3", "错误","") \'增加订单失败提示框
            .AddButton("btnOK","确定")
     End With



    \'存在重复盘点记录时,给出是否重新盘点的提示.
     With wb.AddDialog("","dlg4", "重新盘点确认","您确定要对当前设备重新盘点吗?")
            .AddButton("btnCancel","取消").Kind = 1
            .AddButton("btnOK","继续","./CheckPd.htm?SN=" & e.Cookies("SN") )
          \'  .AddButton("btnOK","继续","./CheckPd.htm?AssetNumber=" & "\'pdJumpFunction()\'" )
     End With




     wb.InsertHTML("<script>assetnumber.focus(); </script>")
     wb.AppendHTML("<script src=\'./ajax/libs/pdScan.js\'></script>")   \'引入脚本文件     
   \' wb.AppendHTML("<script src=\'./ajax/libs/pdJump.js\'></script>")   \'引入脚本文件          
     e.WriteString(wb.Build)


Else 

    wb.InsertHTML("<meta http-equiv=\'Refresh\' c>")      \'如果不含username或password的cookies,那就直接跳转到登录界面
    e.WriteString(wb.Build) \'生成网页



End If

--  作者:有点蓝
--  发布时间:2019/2/18 14:08:00
--  
wb.InsertHTML("<script>assetnumber.focus(); </script>")
改为
wb.InsertHTML("<script>var p = document.getElementById("sn");p.focus();p.select()</script>")
--  作者:ycwk
--  发布时间:2019/2/18 15:31:00
--  
换了后报错:

---------------------------
错误
---------------------------
编译错误:应为逗号、“)”或有效的表达式继续符。



错误代码:wb.InsertHTML("<script>var p = document.getElementById("sn");p.focus();p.Select()</script>")
---------------------------
确定   
---------------------------


--  作者:有点蓝
--  发布时间:2019/2/18 16:19:00
--  
wb.InsertHTML("<script>var p = document.getElementById(""sn"");p.focus();p.select()</script>")