Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 15th, 2005, 2:24 PM   #1
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Smile Hello in JavaScript

Can anyone give me a "Hello Earth!" in JS?
Dietrich is offline   Reply With Quote
Old Feb 15th, 2005, 6:27 PM   #2
EdSalamander
Programmer
 
EdSalamander's Avatar
 
Join Date: Dec 2004
Location: Tucson, AZ, USA
Posts: 80
Rep Power: 4 EdSalamander is on a distinguished road
Send a message via AIM to EdSalamander
<script language="JavaScript" type="text/JavaScript">

  document.write("Hello Earth!");
  alert("Hello Mars!");
  document.getElementById('helloDiv').innerHTML = "Hello Pluto!";

</script>

<br>

<div id="helloDiv"></div>
__________________
I can pick my friends. And I can pick my nose. So, why can't I pick my friend's nose?
EdSalamander is offline   Reply With Quote
Old Feb 16th, 2005, 8:22 AM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Remember that document.write doesn't work in XHTML though - don't ask me why.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 17th, 2005, 1:29 AM   #4
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Talking

Quote:
Originally Posted by EdSalamander
<script language="JavaScript" type="text/JavaScript">

  document.write("Hello Earth!");
  alert("Hello Mars!");
  document.getElementById('helloDiv').innerHTML = "Hello Pluto!";

</script>

<br>

<div id="helloDiv"></div>
Thanks EdSalamander!
Now let's bring in a little of Peter Schilling's Major Tom song!
Dietrich is offline   Reply With Quote
Old Feb 17th, 2005, 12:35 PM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Oooh... just noticed an error. Not an important one, but an error all the same. In the type attribute (not the language attribute) of the <script> tag, "JavaScript" should be in lowercase.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 20th, 2005, 5:31 PM   #6
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
Quote:
Originally Posted by Ooble
Remember that document.write doesn't work in XHTML though - don't ask me why.
Easy fix is...

document.write = function(str) { document.outerHTML += str; }

Btw the language attribute of script is deprecated, to keep up with standards use...
<script type="text/Javascript">
    //<![CDATA[
        /* .. your code here .. */
    //]]>
</script>
__________________


Last edited by tempest; Feb 20th, 2005 at 5:33 PM.
tempest is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:25 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC