更多相关内容...>>WScript中js实现alert,confirm,prompt,msgbox,win64实现
WScript中js实现alert,confirm,prompt,msgbox,win64实现
方法一:js中调用WScript.Shell和vbs,因为WScript.Shell在win64位系统中不再支持,
M50WwK http://blog.numino.net/
所以最后两个函数在32位系统可以直接运行,64位系统必须调用32位cscript才能运行,具体方法:
d8UhV6 http://blog.numino.net/
开始菜单 -> 运行 -> 输入 "%windir%\SysWoW64\cmd.exe"
ZQf34N http://blog.numino.net/
->输入 "cscript /path/to/the/test.js"
4QvMnC http://blog.numino.net/
代码如下,保存为 test.js 即可。
wLhy51 http://blog.numino.net/
function alert(msg) {
TNhN4X http://blog.numino.net/
var wss = new ActiveXObject("WScript.Shell");
r1B66o http://blog.numino.net/
wss.Popup(msg, 0, "提示", 64);
q06AdB http://blog.numino.net/
}
BCB2bC http://blog.numino.net/
function confirm(msg) {
O6IRAy http://blog.numino.net/
var wss = new ActiveXObject("WScript.Shell");
e7j444 http://blog.numino.net/
return wss.Popup(msg, 0, "确认", 1|32) == 1;
w7kszz http://blog.numino.net/
}
F9I418 http://blog.numino.net/
function yesNoCancel(msg) {
3jGp4n http://blog.numino.net/
var shell = new ActiveXObject("WScript.Shell");
LzaemI http://blog.numino.net/
return shell.Popup(msg, 0, "确认", 3|32);
10KovQ http://blog.numino.net/
}
i5nSL6 http://blog.numino.net/
function prompt(msg) {
3YX2DO http://blog.numino.net/
var scriptCtrl = new ActiveXObject("ScriptControl");
UiDbFQ http://blog.numino.net/
msg = escape(msg + "");
WTc66T http://blog.numino.net/
scriptCtrl.Language = "VBScript";
y9c97L http://blog.numino.net/
var sTitle="输入";
1ngakR http://blog.numino.net/
var vbsCode = 'InputBox(Unescape("' + msg + '"), "'+sTitle+'")';
9BBB3t http://blog.numino.net/
//var vbsCode = 'InputBox(Unescape("' + msg + '"), "输入框")';
JEewAV http://blog.numino.net/
//alert(vbsCode);
tUys1x http://blog.numino.net/
return scriptCtrl.Eval(vbsCode);
ONW9pc http://blog.numino.net/
}
0biu4m http://blog.numino.net/
function inputBox(msg,deflt) {
l0CRm7 http://blog.numino.net/
var scriptCtrl = new ActiveXObject("ScriptControl");
B3o2Xo http://blog.numino.net/
msg = escape(msg + "");
sdTJPR http://blog.numino.net/
scriptCtrl.Language = "VBScript";
xJuq1n http://blog.numino.net/
var sTitle="输入";
P1pfmX http://blog.numino.net/
var vbsCode = 'InputBox(Unescape("' + msg + '"),"'+sTitle+'","'+deflt+'")';
q68x2k http://blog.numino.net/
//var vbsCode = 'InputBox(Unescape("' + msg + '"), "输入框")';
4I5IvF http://blog.numino.net/
//alert(vbsCode);
n6zg9Y http://blog.numino.net/
return scriptCtrl.Eval(vbsCode);
2tdp17 http://blog.numino.net/
}
9X9tPT http://blog.numino.net/
alert("hello world");
qgHP0H http://blog.numino.net/
var x=confirm("ok?");
X08gYD http://blog.numino.net/
alert(x);
Zp72WG http://blog.numino.net/
var x=prompt("ok?");
MrokH4 http://blog.numino.net/
alert(x);
14U05t http://blog.numino.net/
var x=inputBox("Pls","val");
jgd2y9 http://blog.numino.net/
alert(x);
8r96hR http://blog.numino.net/
方法二:混合使用js和VBS,保存为 Test.wsf
cx7H8P http://blog.numino.net/

4UWJI1 http://blog.numino.net/
<!-- Test.wsf -->
WXBtzP http://blog.numino.net/
<job id="InputBoxInJS">
PR4ErD http://blog.numino.net/
<script language="VBScript">
ncb3Gk http://blog.numino.net/
Function VBInputBox(promptText)
EW2UIW http://blog.numino.net/
VBInputBox = InputBox(promptText,"Input Box")
QM5WDo http://blog.numino.net/
End Function
a9Q70H http://blog.numino.net/
</script>
55rTSr http://blog.numino.net/
<script language="JavaScript">
6b9904 http://blog.numino.net/
function alert(msg) {
2G5eji http://blog.numino.net/
var wss = new ActiveXObject("WScript.Shell");
55BMpY http://blog.numino.net/
wss.Popup(msg, 0, "提示", 64);
62COMS http://blog.numino.net/
}
UUMRwW http://blog.numino.net/
function confirm(msg) {
Y5xcPn http://blog.numino.net/
var wss = new ActiveXObject("WScript.Shell");
dVdzbn http://blog.numino.net/
return wss.Popup(msg, 0, "确认", 1|32) == 1;
oJDcit http://blog.numino.net/
}
JsfvWj http://blog.numino.net/
function echo(x){
9CBZkt http://blog.numino.net/
var wss = new ActiveXObject("WScript.Shell");
xXHhGj http://blog.numino.net/
wss.Echo(x);
Nu0Q7Z http://blog.numino.net/
}
yJIeq3 http://blog.numino.net/

qlAUvC http://blog.numino.net/
var x = VBInputBox("Enter text")
W4Ft1o http://blog.numino.net/
alert(x);
CDutdo http://blog.numino.net/
echo(x);
m35zpc http://blog.numino.net/
</script>
BZeIJH http://blog.numino.net/
</job>
更多相关内容...>>WScript中js实现alert,confirm,prompt,msgbox,win64实现

Bug报告 |  免责声明 |  联系我们 |  加入收藏

Copyright © 2006 NuminoStudio(www.numino.net) All Rights Reserved