Sunday, May 19, 2024
186
rated 0 times [  190] [ 4]  / answers: 1 / hits: 198196  / 10 Years ago, tue, december 2, 2014, 12:00:00

Hello i was wondering how i can type a javascript game on textmate with my mac and have just a regular .js file but than take the .js file and open it and have it run in chrome like if i have it say Hello World! than Hello World! would show up in chrome.



An example of what I'm after is in this video: http://vimeo.com/105955605


More From » google-chrome

 Answers
32

Around 1:51 in the video, notice how she puts a <script> tag in there? The way it works is like this:



Create an html file (that's just a text file with a .html ending) somewhere on your computer. In the same folder that you put index.html, put a javascript file (that's just a textfile with a .js ending - let's call it game.js). Then, in your index.html file, put some html that includes the script tag with game.js, like Mary did in the video. index.html should look something like this:



<html>
<head>
<script src=game.js></script>
</head>
</html>


Now, double click on that file in finder, and it should open it up in your browser. To open up the console to see the output of your javascript code, hit Command-alt-j (those three buttons at the same time).



Good luck on your journey, hope it's as fun for you as it has been for me so far :)


[#68629] Saturday, November 29, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
angelicajayleneh

Total Points: 216
Total Questions: 110
Total Answers: 100

Location: Sudan
Member since Tue, Aug 3, 2021
3 Years ago
;