faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 119 people (14%) answered Yes
Recently 7 of 10 people (70%) answered Yes


how i can use javascript to launch a program (ex. notepad)

Apr 7th, 2008 23:22
ha mo, Abolfazl Shirazi, Colin Fraser, ali valizadeh,

Colin Fraser Said :
No, why bother though?  
If you are thinking about using a Javascript to launch a program on
someone else's computer, a visitor to your site, then you are asking
them to take a huge leap of faith that you will not hit them with a
virus. Is this a reasonable proposition? I would suggest not.
If you are thinking about launching notepad for the purposes of editing
on your own computer, then try a right click and "View Source" in IE, 
better still, download EditPad Pro, or Lite, or anyone of a number of
text/html editors that will automatically open a browser window for
viewing edited pages.
Abolfazl Shirazi :
The answer of Colin Fraser is not very right.
It is true that it is impossible with javascript BUT you can use 
ActiveX to do it.It is really easy !
For example in the script below you can run windows notepad .
Try it :
<script language="JavaScript" type="text/javascript">
MyObject = new ActiveXObject( "WScript.Shell" )
function RunNotePad() {
MyObject.Run("C:\\windows\\notepad.exe") ;
// The file path should be right >> C:\\windows\\notepad.exe
<h1>Run a Program</h1>
This script launch the file >> c:\windows\notepad.exe<p>
<button onclick="RunNotePad()">Run Windows NotePad</button>
But watch out! The file path in this function should be right !!!
Enjoy it friend !