|
-
May 18th, 2001, 04:39 PM
#1
Thread Starter
New Member
Writing to document?
How do i write to the document? I am new to the WEB?
-
May 18th, 2001, 04:40 PM
#2
Fanatic Member
Simple really, use document.write()
Alcohol & calculus don't mix.
Never drink & derive.
-
May 18th, 2001, 04:43 PM
#3
Thread Starter
New Member
Could you pleas provide an example? I am new and i am just trying to make a hello world program.
-
May 18th, 2001, 04:44 PM
#4
Fanatic Member
I am assuming you have had no javascript experience. Look at this HTML:
Code:
<html>
<head>
<title>document.write example</title>
<script>
var name = prompt("What is your name?", "Bob");
document.write("Hello, " + name + "!");
</script>
</head>
<body>
</body>
</html>
var name = prompt("What is your name?", "Bob");
This makes a variable called 'name' and asks the user what they want it to be. The default is Bob.
document.write("Hello, " + name + "!");
What this does is prints "Hello, " to the window and adds the variable 'name' after it, then adds "!". So, if you gave James as your name, the output would be "Hello, James!".
Last edited by Wynd; May 18th, 2001 at 04:47 PM.
Alcohol & calculus don't mix.
Never drink & derive.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|