This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-05-06 18:26:10

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

How to make a Javascript file?

Hi! I was just wondering how to make a proper .js file. When I usually make one, it just shows the text that I wrote in the browser. How do I fix that?

Offline

 

#2 2012-05-06 18:28:17

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: How to make a Javascript file?

On Windows:

1. Go to the Start Menu-->Accessories-->Command line/whatever it's called
2. Type cd Desktop (assuming the file is on your desktop)
3. Type ren myfile.js.txt myfile.js (assuming the file is called myfile.js)
4. Have Fun (or not)


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#3 2012-05-06 18:34:31

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: How to make a Javascript file?

It says that the file cannot be found.

Offline

 

#4 2012-05-06 18:37:16

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: How to make a Javascript file?

What is the exact path of the file (like C:\\Documents and Settings\Users\ImagineIt\Desktop\file.js)?


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#5 2012-05-06 18:47:33

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: How to make a Javascript file?

I found out I was doing it wrong, but when I run it it just has the code there...

Offline

 

#6 2012-05-06 18:52:24

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: How to make a Javascript file?

Alright. Now you need a way to run it. Is this part of HTML, a userscript, what?


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#7 2012-05-06 18:54:05

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: How to make a Javascript file?

bobbybee wrote:

Alright. Now you need a way to run it. Is this part of HTML, a userscript, what?

Just a js script to test. I'm using notepad++ and when I press launch in chrome it won't work.

Offline

 

#8 2012-05-06 18:55:15

ftf841
Scratcher
Registered: 2012-02-19
Posts: 1000+

Re: How to make a Javascript file?

you cant put it in the desktop put it in the scratch folder so cd program files (X86) cd scratch then type in name of the project.sb

Last edited by ftf841 (2012-05-06 18:55:26)


http://mag.racked.eu/cimage/i9002/Achievement++get%21/Hi+there./mca.png
http://mag.racked.eu/mcimage/i354/Achievement++get%21/CAKE%21%21%21%21%21/mca.png

Offline

 

#9 2012-05-06 18:58:33

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: How to make a Javascript file?

ftf841 wrote:

you cant put it in the desktop put it in the scratch folder so cd program files (X86) cd scratch then type in name of the project.sb

Umm.... What does this have to do with the topic?

Offline

 

#10 2012-05-06 18:58:36

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: How to make a Javascript file?

Okay. Make an HTML file (using the same method as for the javascript file). Put it in the same directory of the javascript. Use this contents:

Code:

<html>
<head>
<script type="text/javascript" src="JAVASCRIPT_FILE_NAME.js"></script>
</head>
<body>
</body>
</html>

I support the Free Software Foundation. Protect our digital rights!

Offline

 

#11 2012-05-06 21:42:03

SJRCS_011
Scratcher
Registered: 2011-02-07
Posts: 1000+

Re: How to make a Javascript file?

bobbybee wrote:

Okay. Make an HTML file (using the same method as for the javascript file). Put it in the same directory of the javascript. Use this contents:

Code:

<html>
<head>
<script type="text/javascript" src="JAVASCRIPT_FILE_NAME.js"></script>
</head>
<body>
</body>
</html>

and any body.onload functions  tongue


http://i.imgur.com/vQqtH.png
Learning to Program in a Nutshell:  "You're missing a closing parentheses" - LS97

Offline

 

#12 2012-05-07 03:49:51

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: How to make a Javascript file?

Save it with a .js extention, or, if it's a userscript, save it with a .user.js extension.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

Board footer