更多相关内容...>>WScript中js实现alert,confirm,prompt,msgbox,win64实现
WScript中js实现alert,confirm,prompt,msgbox,win64实现
方法一:js中调用WScript.Shell和vbs,因为WScript.Shell在win64位系统中不再支持,
14v0f8 http://blog.numino.net/
所以最后两个函数在32位系统可以直接运行,64位系统必须调用32位cscript才能运行,具体方法:
80y1G4 http://blog.numino.net/
开始菜单 -> 运行 -> 输入 "%windir%\SysWoW64\cmd.exe"
tziKuL http://blog.numino.net/
->输入 "cscript /path/to/the/test.js"
3us7K3 http://blog.numino.net/
代码如下,保存为 test.js 即可。
mxKa8f http://blog.numino.net/
function alert(msg) {
r2cKmd http://blog.numino.net/
var wss = new ActiveXObject("WScript.Shell");
MRV1F6 http://blog.numino.net/
wss.Popup(msg, 0, "提示", 64);
iSfLve http://blog.numino.net/
}
vVykAG http://blog.numino.net/
function confirm(msg) {
CyM3JZ http://blog.numino.net/
var wss = new ActiveXObject("WScript.Shell");
61rNhF http://blog.numino.net/
return wss.Popup(msg, 0, "确认", 1|32) == 1;
fUtYMh http://blog.numino.net/
}
2KnbU9 http://blog.numino.net/
function yesNoCancel(msg) {
K4Rjt6 http://blog.numino.net/
var shell = new ActiveXObject("WScript.Shell");
QOJw33 http://blog.numino.net/
return shell.Popup(msg, 0, "确认", 3|32);
6f2uFB http://blog.numino.net/
}
pU3jnb http://blog.numino.net/
function prompt(msg) {
ENmkcs http://blog.numino.net/
var scriptCtrl = new ActiveXObject("ScriptControl");
GhjS0D http://blog.numino.net/
msg = escape(msg + "");
JEmFAa http://blog.numino.net/
scriptCtrl.Language = "VBScript";
Gu9d86 http://blog.numino.net/
var sTitle="输入";
5tLAZU http://blog.numino.net/
var vbsCode = 'InputBox(Unescape("' + msg + '"), "'+sTitle+'")';
Ia527l http://blog.numino.net/
//var vbsCode = 'InputBox(Unescape("' + msg + '"), "输入框")';
LxW9Zr http://blog.numino.net/
//alert(vbsCode);
UeYcYK http://blog.numino.net/
return scriptCtrl.Eval(vbsCode);
SNFrDI http://blog.numino.net/
}
vvS5Jo http://blog.numino.net/
function inputBox(msg,deflt) {
tL1642 http://blog.numino.net/
var scriptCtrl = new ActiveXObject("ScriptControl");
D4EUYK http://blog.numino.net/
msg = escape(msg + "");
4cUVOw http://blog.numino.net/
scriptCtrl.Language = "VBScript";
XFqt8f http://blog.numino.net/
var sTitle="输入";
e1tN1I http://blog.numino.net/
var vbsCode = 'InputBox(Unescape("' + msg + '"),"'+sTitle+'","'+deflt+'")';
4b6idG http://blog.numino.net/
//var vbsCode = 'InputBox(Unescape("' + msg + '"), "输入框")';
W4e6Q2 http://blog.numino.net/
//alert(vbsCode);
2qasIO http://blog.numino.net/
return scriptCtrl.Eval(vbsCode);
3yB1to http://blog.numino.net/
}
Mo3eJP http://blog.numino.net/
alert("hello world");
A1AUCH http://blog.numino.net/
var x=confirm("ok?");
3mSGsY http://blog.numino.net/
alert(x);
fe3bYq http://blog.numino.net/
var x=prompt("ok?");
6fhci0 http://blog.numino.net/
alert(x);
CLYa8A http://blog.numino.net/
var x=inputBox("Pls","val");
98B9nL http://blog.numino.net/
alert(x);
G8ygZD http://blog.numino.net/
方法二:混合使用js和VBS,保存为 Test.wsf
LA4C6u http://blog.numino.net/

Y6Th75 http://blog.numino.net/
<!-- Test.wsf -->
1LhKBw http://blog.numino.net/
<job id="InputBoxInJS">
ypam4v http://blog.numino.net/
<script language="VBScript">
ki38ae http://blog.numino.net/
Function VBInputBox(promptText)
0rj8Rw http://blog.numino.net/
VBInputBox = InputBox(promptText,"Input Box")
vEC5kG http://blog.numino.net/
End Function
nSEkWk http://blog.numino.net/
</script>
yp4z4X http://blog.numino.net/
<script language="JavaScript">
1Lth0B http://blog.numino.net/
function alert(msg) {
JLS3gJ http://blog.numino.net/
var wss = new ActiveXObject("WScript.Shell");
lmi5OW http://blog.numino.net/
wss.Popup(msg, 0, "提示", 64);
pdDpI5 http://blog.numino.net/
}
PXCqtQ http://blog.numino.net/
function confirm(msg) {
OlYlfb http://blog.numino.net/
var wss = new ActiveXObject("WScript.Shell");
afiX8l http://blog.numino.net/
return wss.Popup(msg, 0, "确认", 1|32) == 1;
3lmXz8 http://blog.numino.net/
}
AJsbor http://blog.numino.net/
function echo(x){
17ItcS http://blog.numino.net/
var wss = new ActiveXObject("WScript.Shell");
32uz7V http://blog.numino.net/
wss.Echo(x);
TCN3Gn http://blog.numino.net/
}
1Bib5U http://blog.numino.net/

B7q42m http://blog.numino.net/
var x = VBInputBox("Enter text")
UTa01g http://blog.numino.net/
alert(x);
IX0lM7 http://blog.numino.net/
echo(x);
9oPxly http://blog.numino.net/
</script>
MA8sD7 http://blog.numino.net/
</job>
更多相关内容...>>WScript中js实现alert,confirm,prompt,msgbox,win64实现

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

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