1

Can i make working javascript without open browser or still working after close browser ? Example :

setTimeout(function(){
  test();
},86400000;

setTimeout still working after close browser

5
  • No, javascript runs client-side and in the browser so without having a client or browser it has nothing to run. Not sure what it is you want to achieve but you might want to look into cronjobs if you want source code to run without having a client activating it. Commented May 19, 2016 at 6:32
  • 1
    As others have said: no. There may still be ways to solve your problem, just not the way you think. Explain what you want to achieve instead. Commented May 19, 2016 at 6:33
  • Can you give us proper scenario? What do you want to run after close the browser and where it is run the function after close the browser? Commented May 19, 2016 at 6:33
  • Not sure what you want, but you can take a look at this phantomjs.org Commented May 19, 2016 at 6:38
  • i am getting some variables from other page and saving in my databases, but i want to realize that without reload my browser. My function have 1 day timeout to do it again Commented May 25, 2016 at 6:31

1 Answer 1

1

JavaScript can be run by any interpreter for JavaScript such as the windows script host or node.js runtime environment. But those are different environments with different global scope. For example, using windows, you can save a .js-file from a webapp to the desktop and try to run it. The windows script host will run it but likely fail because it does not have the same objects in its global scope that browsers use.

A script executed inside a browser will always terminate with the browser as the browser is the process executing the script. The script itself isn't in a native executable format and, thus, can't be run by the OS itself instead it requires the browser to interpret the code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.