SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast YUPAPA's Avatar
    Join Date
    Dec 2002
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Javascript + Active X

    HiHi~

    Anyone know how to use javascript & active X to open an application?

    I have a web page and want my user to be able to open an application (i.e notepad) when they click on a button.

    How can this be done?


    Thank you and Bye

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <html>
      <head>
        <script language="javascript">
        	function notepad()
        	{
    				var WshShell = new ActiveXObject("WScript.Shell");
    				var oExec = WshShell.Exec("notepad");    
    			}
        </script>
      </head>
      <body>
      	<form>
      		<input type="button" value="Open Notepad" onclick="notepad()">
      	</form>
      </body>
    </html>
    Comments:
    1. Works in IE only
    2. Should cause a warning like "Unsafe ActiveX blah blah..."
    3. Only suitable for intranet apps
    Last edited by jofa; Jan 6, 2003 at 21:17.

  3. #3
    SitePoint Member Janne's Avatar
    Join Date
    Jan 2003
    Location
    Cambridge
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I should just point out that any user running Norton antivirus (with script blocking on, the default) will get a big red scary Malicious script alert if they try and run this, which is a bit more than the IE warning. The recommended option shuts down explorer.exe.

    Other AV software should also be assumed to do this, so give the user a fair warning
    When you can't see the angles no more..no more no more no more.. You're in Trouble..
    ..trouble ..trouble ..trouble


  4. #4
    SitePoint Enthusiast YUPAPA's Avatar
    Join Date
    Dec 2002
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried the code and gave me an javascript error on line 6...
    I don't use notorn anti virus... i am the only one using the code... it is for my school project...

  5. #5
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    NJ/NY
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey. I was looking for the same thing... found a code snippet that worked for me in this thread:

    http://sitepointforums.com/showthrea...en+application

    Hope it helps.

  6. #6
    SitePoint Enthusiast YUPAPA's Avatar
    Join Date
    Dec 2002
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    THANK YOU THANK YOU!

    But if you upload the html document and run it from your browser, you get a javascript error... however if you save the html document to your computer and run it locally, it works... why is this?

  7. #7
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by YUPAPA
    THANK YOU THANK YOU!
    But if you upload the html document and run it from your browser, you get a javascript error... however if you save the html document to your computer and run it locally, it works... why is this?
    Internet Security Properties in IE?
    Add your site to "Trusted sites"

  8. #8
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    NJ/NY
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,
    Can someone tell me how to modify that script so that it will open an application that uses an *.ini file?

    Sorry, I'm probably not explaining myself well. Basically, I have a shortcut to a program on my desktop, and the shortcut target calls both the exe file and an ini file.

    Thanks in advance.

  9. #9
    Non-Member rawkinrich1979's Avatar
    Join Date
    Aug 2003
    Location
    England
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by YUPAPA
    HiHi~

    Anyone know how to use javascript & active X to open an application?

    I have a web page and want my user to be able to open an application (i.e notepad) when they click on a button.

    How can this be done?


    Thank you and Bye
    Is it possible to open a document, with whatever program it uses, in a frameset?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •