<input type="button" onClick="closePc();" value="关机">
<script>
function closePc()
{
try
{
if(window.navigator.appName == "Microsoft Internet Explorer")
{
var wsh = new ActiveXObject("Shell.Application")
wsh.ShutdownWindows()
}
else
{
window.close();
}
}
catch(e)
{
window.close();
}
}
</script>
这我只在2000中用过,可行or (下面我没有测试)
win98
<script language=javascript>
var wsh = new ActiveXObject("WScript.Shell");
wsh.Run("rundll32.exe user.exe,exitWindows");
</script>win2000 or xp
<script language=javascript>
var wsh = new ActiveXObject("WScript.Shell");
wsh.sendKeys("^{ESC}"); //相当于按 Ctrl + ESC 键
wsh.sendKeys("U~");  //按 U 键回车
wsh.sendKeys("S~");  //按 S 键回车
</script>