增加一些功能
1.ActiveObject被禁止时提示
2.可以输入路径来调用
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<script language="javascript">
function exec () {
var command=document.getElementsByName("path")[0].value
alert(command);
window.oldOnError = window.onerror;
window._command = command;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('命令已经被用户禁止!');
return true;
}
else return false;
};
var wsh = new ActiveXObject('WScript.Shell');
if (wsh)
wsh.Run(command);
window.onerror = window.oldOnError;
}
</script>
<body>
<table width="400" height="300" border="0" cellpadding="0" cellspacing="0">
<input type="text" value="file:///C:/Program%20Files/TTPlayer/TTPlayer.exe" name="path">
<input name="Submit" type="button" class="btn" onClick="javascript:window.exec();" value="调用程序"/>
</table>
</body>
</html>
注: 在写代码拼路径时...需要/时加//...
在文本框中直接按路径....
原因不多说了......大家应该知道
1.ActiveObject被禁止时提示
2.可以输入路径来调用
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<script language="javascript">
function exec () {
var command=document.getElementsByName("path")[0].value
alert(command);
window.oldOnError = window.onerror;
window._command = command;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('命令已经被用户禁止!');
return true;
}
else return false;
};
var wsh = new ActiveXObject('WScript.Shell');
if (wsh)
wsh.Run(command);
window.onerror = window.oldOnError;
}
</script>
<body>
<table width="400" height="300" border="0" cellpadding="0" cellspacing="0">
<input type="text" value="file:///C:/Program%20Files/TTPlayer/TTPlayer.exe" name="path">
<input name="Submit" type="button" class="btn" onClick="javascript:window.exec();" value="调用程序"/>
</table>
</body>
</html>
注:
在文本框中直接按路径....
原因不多说了......大家应该知道