Jump to content

How to open Wordpad with a File?


markymark

Recommended Posts

Hi,I am looking to use a javascript button to open a wordpad file when the button is pressed.This is the code so far:<script language=javascript>function openwindow() {window.open("C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe")}</script><form><input type=button value="Open Window" onclick="openwindow()"></form>TIAMarkymark

Link to comment
Share on other sites

But you can, only it is often not allowed or at least every client is different :)Use environment variables for NT machines, to specify the home directory. it is possible that it isn't on the C drive, or in another folder.First, replace window.open() by window.external.open(), second:If you're sure the file (or program) you want to open is to be found in a certain folder, use this:

"%HOMEDRIVE%/Program Files/Windows NT/Accessories/wordpad.exe"
(nevermind the slashes, windows both accepts slashes and backslashes)But remind it would cause an error and a socalled "user abort" in the javascript, when it was not found :)[*Edit:]Forget what I have said here, I just tested it *again* and it doesn't work. I guess your are indeed not alolowed to open files via the browser :)
Link to comment
Share on other sites

This can be compared to the "View Source" option in the context menu, right? If you want to simulate that contextmenu option, open Notepad with the currnet document, then this would also not be allowed while it is from a browser windo, thus a website, ? Anyway, if that is the case, websites not being allowed to open files such way, then wordpad cannot be opened either :)

Link to comment
Share on other sites

maybe somehow if you could use some sort of command shell, all you need to make it do is type notepad and hit enter and it will oepn :). Thats just in shells though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...