jamesadrian Posted April 11, 2016 Share Posted April 11, 2016 I am just starting to learn some java script. I am looking for a way to write a script on my desktop (which I have done) and see it work on two files on my desktop. I have only seen java script work on my website. Thank you for your help. Jim Adrian Link to comment Share on other sites More sharing options...
davej Posted April 11, 2016 Share Posted April 11, 2016 You can do it all in one file. <!DOCTYPE html> <head lang="en"> <meta charset="UTF-8"> <title>test</title> <style> h1{color:red} </style> </head> <body> <h1>TEST</h1> <div id="msg"> </div> <script> var str = "<b>Hello World!</b>"; document.getElementById('msg').innerHTML = str; </script> </body> </html> Link to comment Share on other sites More sharing options...
thescientist Posted April 14, 2016 Share Posted April 14, 2016 When you say on your desktop, what do you mean? A native application or running in a web browser? Link to comment Share on other sites More sharing options...
jamesadrian Posted April 14, 2016 Author Share Posted April 14, 2016 I have copied the code given above into a text editor and gave it the name test.htm and when I have it on my desktop and click on it my browser renders it as a local file without going on line. This is great! I hope that I can make a few text files and have a script in test.htm manipulate data in the files on my desktop. Of course I will need to know much more javascript to do that. I am willing to learn it all if this goal can be done. Will any additional software be needed in order to do this? Thank you for your help. Jim Adrian Link to comment Share on other sites More sharing options...
justsomeguy Posted April 15, 2016 Share Posted April 15, 2016 You may need to change your browser's security settings, I believe that files running locally cannot send requests for other files by default. Link to comment Share on other sites More sharing options...
Ingolme Posted April 15, 2016 Share Posted April 15, 2016 They can load Javascript files with the script tag, but AJAX requests are blocked. Link to comment Share on other sites More sharing options...
thescientist Posted April 15, 2016 Share Posted April 15, 2016 Is this just for something you are doing on your own, or something you are looking to share with other people, so they can run it too? Link to comment Share on other sites More sharing options...
jamesadrian Posted April 15, 2016 Author Share Posted April 15, 2016 (edited) Is this just for something you are doing on your own, or something you are looking to share with other people, so they can run it too? I want to write programs that other people can run on their desktop. Does anything prevent this? Thank you for your help. Jim Adrian Edited April 15, 2016 by jamesadrian Link to comment Share on other sites More sharing options...
jamesadrian Posted April 15, 2016 Author Share Posted April 15, 2016 Are these two links on topic? http://www.html5rocks.com/en/tutorials/file/dndfiles/https://www.nczonline.net/blog/2012/05/08/working-with-files-in-javascript-part-1/ Jim Adrian Link to comment Share on other sites More sharing options...
thescientist Posted April 15, 2016 Share Posted April 15, 2016 No, that's not a problem per se. It's just that writing code and distributing code are different objectives and often involve different skill sets, especially if you are specifically targeting desktop users. That said, it's more of a disclaimer is all. Have you heard of Node? It is a JavaScript runtime (akin to what you get when running JavaScript in the browser) except that it is a program that you can have your users install ahead of time and can be run on their own machines, like a native app. From there, you could publish this project to NPM and then users could also use it to install your project (with all its source and dependencies) and from there a single command could be run in order to launch your app. Any reason you are favoring desktop vs. the web though? Link to comment Share on other sites More sharing options...
musicman Posted April 15, 2016 Share Posted April 15, 2016 Security? Link to comment Share on other sites More sharing options...
jamesadrian Posted April 15, 2016 Author Share Posted April 15, 2016 The forum front page says that this subject has had no comments or views. Jim Adrian Link to comment Share on other sites More sharing options...
justsomeguy Posted April 15, 2016 Share Posted April 15, 2016 I see 11 replies and 357 views. Link to comment Share on other sites More sharing options...
jamesadrian Posted April 15, 2016 Author Share Posted April 15, 2016 I see this picture attached. Jim Adrian Link to comment Share on other sites More sharing options...
jamesadrian Posted April 15, 2016 Author Share Posted April 15, 2016 No, that's not a problem per se. It's just that writing code and distributing code are different objectives and often involve different skill sets, especially if you are specifically targeting desktop users. That said, it's more of a disclaimer is all. Have you heard of Node? It is a JavaScript runtime (akin to what you get when running JavaScript in the browser) except that it is a program that you can have your users install ahead of time and can be run on their own machines, like a native app. From there, you could publish this project to NPM and then users could also use it to install your project (with all its source and dependencies) and from there a single command could be run in order to launch your app. Any reason you are favoring desktop vs. the web though? I want the simplest way for users to use the program. I would like to email it to them and have it run without any other downloading or complications on their desktop. Can this be done? Jim Adrian Link to comment Share on other sites More sharing options...
justsomeguy Posted April 15, 2016 Share Posted April 15, 2016 If that's what you're going for then Javascript might not be the best tool. What kinds of things do you want the program to do? Link to comment Share on other sites More sharing options...
jamesadrian Posted April 16, 2016 Author Share Posted April 16, 2016 Moderator, I want the program to take a byte from file A, and another from file B, and use an arithmetic or logical operation on the two bytes and place the result in file C. All three files would be offline, possibly in a folder on the desktop. The program would need to increment the byte address in all cases. I don't care what I would need to use as names of the files or what file types might be used, so long as any eight bits would work as a byte. I would not appreciate a severe limit on the size of these files. One megabyte might be acceptable. If I can't create a file with the script, I would e happy to create them before the script is run. If file C happens to contain only ASCII characters that can theoretically be displayed, I would hope there would be a way to display them or use file C as a text file after the fact (after the script has run). Secondarily, it would be nice if I could interleave a file or use one file to determine a permutation of another file. Thank you for your help. Jim Adrian Link to comment Share on other sites More sharing options...
Ingolme Posted April 16, 2016 Share Posted April 16, 2016 You should look into a real programming language like C++, Java or something of the sort. Javascript can only read files in particular cases and it cannot write to any files. On a desktop it is even more limited. Link to comment Share on other sites More sharing options...
davej Posted April 16, 2016 Share Posted April 16, 2016 I would suggest Java. You can download the JDK and a developer IDE here... http://www.oracle.com/technetwork/java/javase/downloads/jdk-netbeans-jsp-142931.html For security reasons Javascript is severely restricted when it comes to accessing files. Other options would be C# or Python. C++ is rather old and clunky. Link to comment Share on other sites More sharing options...
thescientist Posted April 18, 2016 Share Posted April 18, 2016 I think the important thing here to keep in mind for the OP is not just looking for development environment, but simple distribution pipeline as well. For that reason, I would still recommend Node. You can continue to write in JS, there are installers for Windows / OSX that anybody can install from to keep that overhead low, and it comes with a package manager. On top of that, you can use Node / NPM to install a webserver for users as well. All in all, it provides a very robust ecosystem for developers, and a pretty straightforward consumption process for users. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 18, 2016 Share Posted April 18, 2016 It seems like a little bit of overkill. It would be pretty simple to write a small C program to do that, compile it into an executable, and send it to people. 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