โดย icphp » 01/07/2006 11:06 am
มี 2 แบบ นะเท่าที่รู้ คือ
1.ใช้ object document
2.สร้าง object ด้วย WScript.shell แล้ว เรียกใช้ method run() ของ WScript.shell
ตัวอย่างแบบ แรก
[code]<SCRIPT>
function runpro_onclient() {
// document.location.href = "D:/cmd.php"; // ตัวอย่างการ รันไฟล์
document.location.href = "D:/WINDOWS/NOTEPAD.exe"; // ตัวอย่างรันโปแกรม
}
</SCRIPT>
<body onload="runpro_onclient()">[/code]
แบบที่ 2
<SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
function runpro_onclient() {
var myshell = new ActiveXObject( "WScript.shell" );
myshell.run( '"c:/program files/microsoft
office/office11/excel.exe" "c:/yourfilename.xls"', 1, true );
}
</SCRIPT>
<!------------------------------------------------------------------->
<INPUT
TYPE="button"
NAME="button1"
VALUE="คลิกที่นี่เพื่อ Run Excel และกำหนดไฟล์ในการไปพร้อมกันด้วย"
ONCLICK="runpro_onclient()"
>
</INPUT>
[size=150]มี 2 แบบ นะเท่าที่รู้ คือ
1.ใช้ object document
2.สร้าง object ด้วย WScript.shell แล้ว เรียกใช้ method run() ของ WScript.shell
ตัวอย่างแบบ แรก
[code]<SCRIPT>
function runpro_onclient() {
// document.location.href = "D:/cmd.php"; // ตัวอย่างการ รันไฟล์
document.location.href = "D:/WINDOWS/NOTEPAD.exe"; // ตัวอย่างรันโปแกรม
}
</SCRIPT>
<body onload="runpro_onclient()">[/code]
แบบที่ 2
<SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
function runpro_onclient() {
var myshell = new ActiveXObject( "WScript.shell" );
myshell.run( '"c:/program files/microsoft
office/office11/excel.exe" "c:/yourfilename.xls"', 1, true );
}
</SCRIPT>
<!------------------------------------------------------------------->
<INPUT
TYPE="button"
NAME="button1"
VALUE="คลิกที่นี่เพื่อ Run Excel และกำหนดไฟล์ในการไปพร้อมกันด้วย"
ONCLICK="runpro_onclient()"
>
</INPUT>[/size]