iDevGames Forums
JavaScript - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: JavaScript (/thread-2770.html)



JavaScript - Wise Druid - Feb 16, 2008 03:34 PM

I've got this book on JavaScript(Wrox beginning JavaScript) it's good but...
I cant run my code, on the instructions (for windows) i edit in the text editor and open with Internet explorer, I tried that in mac and it doesnt work Annoyed

Does anyone know how to run my JavaScript/HTML code on a mac??

----------------------------------------------------
Solution:
What you need to do, is while in textedit, go to the "Format" menu and choose "Make plain text", save it with the extension .html and open! ^^

thank u for all that helped!


JavaScript - FlamingHairball - Feb 16, 2008 04:01 PM

What text editor are you using on the Mac?


JavaScript - AnotherJake - Feb 16, 2008 04:53 PM

First thing that comes to mind is that the line endings are incorrect. Another thing that comes to mind is that I wouldn't bother with Internet Explorer for anything since it sucks so bad -- especially on Windows, but also on the Mac. The last thing that comes to mind is, are you sure your Javascript is correct?


JavaScript - FlamingHairball - Feb 16, 2008 05:16 PM

Or maybe he accidentally saved it as richtext…


JavaScript - Wise Druid - Feb 16, 2008 05:44 PM

I use the TextEdit application.

And by what i see on windows the internet explorer(which i also agree that it sucks) when opens a file with HTML, it reads the code and interprets it(including the JavaScript in the code), but it doesn't do that if in the options menu it's marked not to do, in that case it just opens the text file with the code on it(this is what happens in the mac too, with firefox and safari).

the problem isnt with the code or the format.

I just need to activate something to interpret the code(HTML/JS) and execute it, or maybe an app that also does that.


JavaScript - igame3d - Feb 16, 2008 06:09 PM

Textedit normally saves RTF
And if you are saving as HTML, it thinks what you typed is styled text
that is supposed to show up on the page.

Try changing fonts,sizes and colors and save as html..you'll see what I mean.

Check out Smultron and Editra for your coding text needs.

You'll be good to go.
You should not embed your javascript in the Html by the way.
Save as a .js file and use
Code:
<script src="thescriptname.js" type="text/javascript">
//or
<script language="JavaScript" src="yourfile.js"></script>

in the body of your HTML code.




You should be able to test your .js files and scripts in the browser address bar.
Ex:
jalert("It works!")
file:///path/to/your/javascript.js
file:///path/to/your/webpage.html


JavaScript - FlamingHairball - Feb 16, 2008 06:12 PM

What you need to do, is while in textedit, go to the "Format" menu and choose "Make plain text". That way, when you save it, it will be plain text. You can then change the extension to .html and open it with a web browser.


JavaScript - Wise Druid - Feb 16, 2008 06:16 PM

No that isn't the problem (i think). In the preference of the TextEdit it automatically changes the font when save to html. i will keep trying and edit here later


Edit:

Wohooooooo it worked!!!!

I have to convert it to plain text and save it to .HTML and just open it in safari!!!

later i will try i game3d's method, should work too. ohh yes and i did this simple code to test if it works:

Code:
<html>
    <head>
        <title>Work!!!</title>
    </head>
    <body>
        <script language="JavaScript">
            document.write("Work!!");
        </script>
    </body>
</html>
ohh and one more question how do i make that box around my code???


JavaScript - AnotherJake - Feb 16, 2008 06:56 PM

Glad you got it to work!

Wise Druid Wrote:ohh and one more question how do i make that box around my code???
On the message editing page, select the code you want to be in a code box and click on the # sign on the right, just above the editor. Or you can manually add the tags yourself.


JavaScript - Wise Druid - Feb 16, 2008 07:13 PM

Code:
//Thanks ;p

Yes now it works fine!! just need the TextEdit and safari!
Ohh and you can use JS to make dashboard widgets (using Xcode).

But i don't think there is an IDE for HTML/JS...


JavaScript - igame3d - Feb 16, 2008 07:54 PM

Wise Druid Wrote:But i don't think there is an IDE for HTML/JS...

Dreamweaver?

Or maybe OpenMocha?, which is free.


JavaScript - FlamingHairball - Feb 16, 2008 09:30 PM

Wise Druid Wrote:No that isn't the problem (i think). In the preference of the TextEdit it automatically changes the font when save to html. i will keep trying and edit here later


Edit:

Wohooooooo it worked!!!!

I have to convert it to plain text and save it to .HTML and just open it in safari!!!

later i will try i game3d's method, should work too. ohh yes and i did this simple code to test if it works:

Code:
<html>
    <head>
        <title>Work!!!</title>
    </head>
    <body>
        <script language="JavaScript">
            document.write("Work!!");
        </script>
    </body>
</html>
ohh and one more question how do i make that box around my code???

Glad it worked. I am currently trying TacoHTMLEdit which imho is pretty good. You would probably just want to try out all the suggestions and choose for yourself.


JavaScript - Shivers - Feb 23, 2008 08:38 AM

Wise Druid Wrote:But i don't think there is an IDE for HTML/JS...

Checkout Textmate-- or Coda if you want a little more structure. Both work grand for JS and HTML.


JavaScript - Wise Druid - Oct 15, 2008 05:55 AM

I used Taco HTML Edit, And it worked for me!