Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • How an we open using window.open method? I want to open the content using window.open. Window.open should open the content. Commented Apr 28, 2014 at 10:05
  • @user3463768: you can't. You can't open a file on the client's disk using window.open. The only thing you could do using window.open is window.open('file://<absolute path to file here>');. But there's no guarantee that'll work. JS is code that is sent to the client via the network. If it were allowed to access local files willy-nilly, then that would be incredibly unsafe. you really should look into other ways to do whatever it is you are trying to do Commented Apr 28, 2014 at 11:15
  • If you are trying to load an HTML file that is hosted by your machine, then window.open('http://127.0.0.1/dirname/file.ext') will work, but that requires you to have a server running Commented Apr 28, 2014 at 11:17
  • Is there any alternative for this? My files will be stored on local system. I am using HTML file upload control to read the file from local system and displaying the path in Grid when user clicks add button after browse from file system. So we show the path of the file in grid. User selects the path in grid and clicks on open button. The file should be opened or should ask for save. Any other way you think we can achieve this requirement? Commented Apr 28, 2014 at 11:36
  • @user3463768: Sounds like you're barking up the wrong tree with choosing JavaScript. You're talking about uploading files, which implies a server-side technology. I'd use AJAX + whatever server-side language you're using on the server Commented Apr 28, 2014 at 11:45