Reputation: 13
I am new to programming and am having trouble trying to open my Javascipt program to a web browser for testing. How is this done through Sublime Text Edit? I don't see any option for running to a browser. I can go to build then run but it all complies at the bottom of the screen. So how is it run directly to chrome?
Thank you
Upvotes: 1
Views: 2171
Reputation: 83556
Browsers load HTML pages. In HTML page you have an option to load and execute JavaScript code via <script>
tag.
Create a HTML page
Put it to the same folder with your .JS file
In HTML have a <script>
tag that loads your code:
<html>
<head>
<script src="myjsfile.js"></script>
</head>
<body>
</body>
</html>
Open this HTML file in Chrome (drag and drop, double click, etc.)
(Note: Nowadays there are also command line JavaScript programs which are run with NodeJS, but they are not usually for programming novices).
Upvotes: 2