Simple Machine Codes
March 28, 2024, 05:17:13 pm
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to SMC, the best place for your SMF For Free Codes
 
  Home Help Search Arcade Gallery Affiliates Code Index Staff List Calendar Members Login Register  

document.write() and alert() Functions

Pages: [1]   Go Down
  Print  
Author Topic: document.write() and alert() Functions  (Read 967 times)
0 Members and 1 Guest are viewing this topic.
Agent Moose
Administrator

Offline Offline

Gender: Male
Posts: 2,672



View Profile WWW
« on: August 26, 2007, 03:03:24 pm »

document.write()
The document.write() function allowes you to write anything onto a page.

So, if I want to say Hello World, I would use this:
Code:
<script type="type/javascript">
document.write("Hello World");
</script>

You can also use HTML with it too.
Another thing you can do is call other functions or variables through a document.write() function.  here is an example of a variable being used:

Code:
<script type="type/javascript">
var text = "Hello World";
document.write(text);
</script>

You may also use HTML there.

alert()
The alert() function alowes you to create a pop-up.  So, if you wanted to create a pop-up with the text Hello World, you would do this:

Code:
<script type="type/javascript">
alert("Hello World");
</script>

You may use HTML with it.  Just like the document.write() function, you can use a variable.

Code:
<script type="type/javascript">
var text = "Hello World"
alert(text);
</script>

That would make do the same thing as the alert("Hello World").
« Last Edit: May 20, 2009, 07:59:23 am by Agent Moose » Report Spam   Logged

Share on Facebook Share on Twitter

deathwilldie
100 Club Member

Offline Offline

Posts: 214


View Profile WWW
« Reply #1 on: September 08, 2007, 07:39:06 pm »

I like the alert thing but it gets annoying.
Report Spam   Logged

Agent Moose
Administrator

Offline Offline

Gender: Male
Posts: 2,672



View Profile WWW
« Reply #2 on: September 15, 2007, 08:57:04 am »

Oh yea.  Alert is a very annoying function, but, there are alot of codes that use it...none of mine though.
Report Spam   Logged

clankfan1
Members

Offline Offline

Gender: Male
Posts: 27



View Profile
« Reply #3 on: January 02, 2008, 09:59:54 pm »

var text = "Welcome!"
document.write(text)
var color = "red"
document.write(color)


How could that work?
Report Spam   Logged



Code:
<a href='http://smcodes.smfforfree3.com/index.php' target='_blank'><img src='http://i1.tinypic.com/8ghqsf5.gif' alt='Simple Machine Codes'></a>
Celebrus
Artificially Conscious
Administrator

Offline Offline

Gender: Male
Posts: 1,337


aka Omikron


View Profile WWW
« Reply #4 on: January 03, 2008, 02:31:50 am »

var text = "Welcome!"
document.write(text)
var color = "red"
document.write(color)


How could that work?

Put script tags around it.
Code:
<script>
var text = "Welcome!"
document.write(text)
var color = "red"
document.write(color)
</script>

Then put it somewhere, lol. It should work.
Report Spam   Logged

Agent Moose Jr.
Ultra Contagious
Global Moderator

Offline Offline

Gender: Male
Posts: 1,045



View Profile WWW
« Reply #5 on: January 04, 2008, 12:41:44 pm »

or you could do this

Code:
<script>
function text()
var text = "Welcome!"
document.write(text)
var color = "red"
document.write(color)
</script>

im not completely sure that will work but try it
Report Spam   Logged

Newest:

Celebrus
Artificially Conscious
Administrator

Offline Offline

Gender: Male
Posts: 1,337


aka Omikron


View Profile WWW
« Reply #6 on: January 04, 2008, 08:41:38 pm »

That may not work. This will though:
Code:
<script>
function text() {
var text = "Welcome!"
document.write(text)
var color = "red"
document.write(color)
}
text();
</script>
Report Spam   Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy