Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 3rd, 2013, 10:37 AM
XooKi3 XooKi3 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 XooKi3 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 46 sec
Reputation Power: 0
How i you write external .js scripts?

hello all,

I am just starting to learn the java lingo. done abit on codeacademy and have just started on the w3schools site today.

Anyways i have come across the external scripting part and basically my question is what JavaScript will i put in the "myScript.js" file? i tried to write my own .js file, i put a function in it to change the "A Paragraph." text on the button click

Code:
<html>
<body>

<h1>My Web Page</h1>

<p id="demo">A Paragraph.</p>

<button type="button" onclick="myFunction()">Try it</button>

<p><strong>Note:</strong> myFunction is stored in an external file called "myScript.js".</p>

<script type="text/javascript" src="myScript.js"></script>

</body>
</html>


Sorry if that made no sense, i am very very green when it comes to all of this (as you can probably tell :P)

Any help is much appreciated.

Reply With Quote
  #2  
Old January 3rd, 2013, 12:27 PM
stdunbar's Avatar
stdunbar stdunbar is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 2,399 stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 18 h 26 m 27 sec
Reputation Power: 1660
Send a message via Yahoo to stdunbar Send a message via Google Talk to stdunbar
I'll never forgive Netscape and Sun for the marketing driven rename of Mocha and LiveScript to JavaScript. Regardless of how they sound, JavaScript and Java have nothing really in common other than they are both programming languages. They are aimed at very different areas. Take a look at this post for a bit more information.

Nevertheless, many of us bridge both worlds. You would write in your JavaScript file any code that you might normally put into an HTML file. For example (derived from here)

html Code:
Original - html Code
    <!DOCTYPE html> <html> <head> <script> function myFunction() {     alert("Hello! I am an alert box!"); } </script> </head> <body> <input type="button" onclick="myFunction()" value="Show alert box" /> </body> </html>


Or...

The file hello.html
html Code:
Original - html Code
    <!DOCTYPE html> <html> <head> <script type="text/javascript" src="hello.js"></script> </head> <body> <input type="button" onclick="myFunction()" value="Show alert box" /> </body> </html>


and the file hello.js

javascript Code:
Original - javascript Code
  1. function myFunction() {
  2.     alert("Hello! I am an alert box!");
  3. }


You're simply putting the JavaScript into a separate file.
__________________
Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > How i you write external .js scripts?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap