本帖最后由 xiaolijian916 于 2021-8-10 14:57 编辑
以下原示例代码,!tr!行记录不超于5行时,页面正常弹出,大于5行页面未弹出(怀疑是拼接过长导致无法执行)- REM ----------------------------------------------------------------------------------------->【清理过时的无线网络连接信息(采用hta构建方式实现)】
- :clear-wlan
- ECHO 清理完毕
- REM 【第二种】说明:hta=HTML Application简写,意为HTML页面应用程序,扩展性极强【弹窗未居中,需计算中心坐标】
-
- REM 自定义函数脚本封装
- set script="<script type='text/javascript'> window.resizeTo(800,500);window.moveTo((!xpixels!-800)/2,(!ypixels!-500)/2); "
- set script=!script!"function cls(){
- set script=!script!" var wifi = document.getElementsByName('wifi');"
- set script=!script!" var msg = "", array = [];"
- set script=!script!" for(var i = 0; i < wifi.length; i++){"
- set script=!script!" if(wifi[i].checked) {"
- set script=!script!" array.push(wifi[i].value);"
- set script=!script!" msg += ('【'+ wifi[i].sn + '】- ' + wifi[i].value + '\r');"
- set script=!script!" }"
- set script=!script!" }"
- set script=!script!" if(array.length == 0){"
- set script=!script!" alert('请至少选择一项');"
- set script=!script!" }else{"
- set script=!script!" var rs = confirm('您选中【'+ array.length +'】项分别是:\r-----------------------\r'+ msg +'-----------------------\r★ 此操作无法撤销,请您再次确认!');"
- set script=!script!" if(rs == true){"
- set script=!script!" new ActiveXObject('Scripting.FileSystemObject')).GetStandardStream(1).Write(array.join('&');close();"
- set script=!script!" }"
- set script=!script!" }"
- set script=!script!"}"
- set script=!script!"</script>"
-
- REM 页面样式封装
- set style="<style> body {font-family:微软雅黑} "
- set style=!style!"input[type=button] {background-color:#3399FF;border:0px;color:#FFFFFF;width:100px;height:35px;margin-left:30px;margin-right:30px;font-size:15px;font-weight:800;}; "
- set style=!style!"tr {height:30px;background-color:#CCFFFF}; tr.row {font-size:15px;font-weight:800;color:#FFFFFF;background-color: #3399FF}; td.sn {width:70px}; "
- set style=!style!"</style>"
-
- REM 表格内容封装
- set table="<table style='border:1px solid #3399FF;width:700px;' cellspacing='0'>"
- set table=!table!"<tr class=row>"
- set table=!table!" <td class='sn'> 序号</td>"
- set table=!table!" <td>名称</td>"
- set table=!table!" <td>口令</td>"
- set table=!table!" <td class='sn'> 序号</td>"
- set table=!table!" <td>名称</td>"
- set table=!table!" <td>口令</td>"
- set table=!table!"</tr>"
- REM 动态拼装行记录(数据量!tr!=50行左右)
- set table=!table!!tr!
- set table=!table!"<tr style='height:65px'>"
- set table=!table!" <td colspan=6 align='center' style='border:0px solid red'>"
- set table=!table!" <hr style='color:#3399FF;height:1px;'>"
- set table=!table!" <input type='button' value='清 理' onclick='cls()'>"
- set table=!table!" <input type='button' value='取 消' onclick='close()'>"
- set table=!table!" </td>"
- set table=!table!"</tr>"
- set table=!table!"</table>"
-
- REM 构建完整页面
- set htatxt="<title>清理无线网络连接历史记录</title> "
- set htatxt=!htatxt!!script!!style!!table!
- set htatxt=!htatxt:"=!
- REM set table=!table:"=!
- ECHO !htatxt!
- REM 封装将多行文本拼接为一行,增强可读性及易维护
- set htatxt='mshta "about:<hta:application scroll=no border=thin maximizeButton=no minimizeButton=no showintaskbar=no />!htatxt!"'
- REM echo !htatxt! >htatxt.txt
- set pname=
- set pvalue=
- for /f "tokens=1,2 delims=^=" %%a in (!htatxt!) do (
- REM 根据页面操作返回数据执行后续业务逻辑代码
- )
复制代码
|