October 21, 2018, 09:08:25 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to Revolution X, where Coding meets Graphics.
 
  Home Help Search Arcade Affiliates Staff List Calendar Members Login Register  

document.write() and alert()

Pages: [1]   Go Down
  Print  
Author Topic: document.write() and alert()  (Read 485 times)
Agent Moose
Administrator
Adminitrator
Offline Offline

Gender: Male
Posts: 1,470



View Profile WWW
Badges: (View All)
« on: May 29, 2009, 08:28:09 am »

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").
Report Spam   Logged


Social Buttons

Andrew
Exclusive
Exclusive
Offline Offline

Gender: Male
Posts: 539



View Profile WWW
Badges: (View All)
« Reply #1 on: May 29, 2009, 09:13:03 am »

This ones, pretty simple, but really good Smiley

So, if I used this, would it only show up once on the forum? Or would it come up everytime someone refreshed?
Code:
<script type="type/javascript">
alert("Welcome to Partners in Crime!");
</script>
Report Spam   Logged

Agent Moose
Administrator
Adminitrator
Offline Offline

Gender: Male
Posts: 1,470



View Profile WWW
Badges: (View All)
« Reply #2 on: May 29, 2009, 09:23:08 am »

Every time someone refreshes.
Report Spam   Logged


Mojobojo82
MVP
MVP
Offline Offline

Gender: Male
Posts: 838


View Profile
Badges: (View All)
« Reply #3 on: June 17, 2009, 05:26:45 am »

That would be annoying Tongue I thought there was one When you first go on the Website and when you leave it Tongue
Report Spam   Logged






Exilis
Optimistic & Creative
Global Moderator
Global Moderator
Offline Offline

Posts: 929


View Profile
Badges: (View All)
« Reply #4 on: June 17, 2009, 05:43:33 am »

For that you would need to use cookies. Cookies in any language can be confusing, but maybe Moose will make a tutorial about them sometime.
Report Spam   Logged

Global Mod, (sort of) at your service.

http://twitter.com/timothyaveni

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum | Buy traffic for your forum/website

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