markymark Posted August 9, 2006 Share Posted August 9, 2006 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 More sharing options...
Chandra.Vedantham@gmail.com Posted August 9, 2006 Share Posted August 9, 2006 Hi,If you are trying to use this javascript in a HTML Page that is served by a server, you cannot achieve this as javascript cannot access files on the client machine. Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 9, 2006 Share Posted August 9, 2006 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 More sharing options...
Chocolate570 Posted August 9, 2006 Share Posted August 9, 2006 That would make it easier for a virus to send data to a site. Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 9, 2006 Share Posted August 9, 2006 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 More sharing options...
aspnetguy Posted August 9, 2006 Share Posted August 9, 2006 yeah fat chance getting people to give you the proper permissions to open executeables on their computer....then again people are morons. Link to comment Share on other sites More sharing options...
reportingsjr Posted August 9, 2006 Share Posted August 9, 2006 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 More sharing options...
aspnetguy Posted August 9, 2006 Share Posted August 9, 2006 don't shells need user permission to run sort of like and exe file. You can't just make it run automatically and seemlessy from a website...that I am aware of. Link to comment Share on other sites More sharing options...
reportingsjr Posted August 9, 2006 Share Posted August 9, 2006 True enough.. But they can run by them selves, cron jobs Link to comment Share on other sites More sharing options...
Chocolate570 Posted August 9, 2006 Share Posted August 9, 2006 Im sure there's some stupid insecure active x control that allows you to do this. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now