Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.


Post Reply  Post Thread 

JavaScript Alerts

Post Bank
Posting Manager
******

Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Download FileShield free from PermissionResearch!
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.

Signin to Remove this Post

ivenms
Administrator
*******


Posts: 2,177
Group: Administrators
Joined: Sep 2006
Status: Offline
Reputation: 14
Points: 4389 (Donate)
Post: #1

Smile JavaScript Alerts


Well, you want to add one of those JavaScript alert boxes that come out of nowhere, don't you? Okay, let's begin with the alert box that just tells the viewer something you want them to know. Here's the alert command:

alert('your choice of text')

Now, to use it, we'll need to place it inside another command. Let's use one we are familiar with, the onMouseover command. The following script will alert the user that you did not want them trying to click this particular link when they move their mouse over it.

<A HREF="noplace" onMouseover="alert('Hey! I said not to try clicking this link!')"> Don't click this link!</A>


Yes! Now you can drive your friends insane with a bunch of fake links! Here's what all the commands are doing:

onMouseover=" "
This tells the browser to execute the command or function inside the double quote marks when the user moves their mouse over the link.

alert('Hey! I said not to try clicking this link!')
Instructs the browser to display the text inside the single quotes in an alert window.

That was nice, but could you make something a little more annoying? Of course! It's called the "alert as soon as you open the page!" alert. Just think, you could tell people stuff before they ever see anything on the page! The trick: placing the alert command inside the <HEAD> </HEAD> tags! You will now get to use the old SCRIPT tags I mentioned a couple of sections ago to set off the JavaScript from the other stuff. Here is the code:

<HEAD>
<TITLE>Cool JavaScripts</TITLE>

<SCRIPT language="JavaScript">
<!-- hide from old browsers

alert('Welcome to my Web Site!');

//-->
</SCRIPT>

</HEAD>

This will display the alert before the page starts loading. When you hit "OK" the page will go on and load normally.

Here's the breakdown:

<SCRIPT language="JavaScript">
This tag lets the browser know you are using JavaScript commands here.

<!-- hide script from old browsers
This makes sure older browsers don't display your script as text on the page.

alert('Welcome to my Web Site!');
This is your alert. Put your mesage inside the single quotes. Notice the semicolon at the end, this is what separates JavaScript commands.

//-->
Stops hiding the script from old browsers.

</SCRIPT>
Ends the JavaScript commands.


Read: General Rules & Policies before posting.
Make Money By Posting | Earning and Exchanging Points | Add Your Links
15-09-2006 03:04 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
Smile Learn JavaScript Basics ivenms 1 763 14-07-2008 06:20 PM
Last Post: ratedguy
Toungue Image Rollover Script Javascript ratedguy 0 144 14-07-2008 06:15 PM
Last Post: ratedguy
  I'm New to Javascript MaGiC DaN90 3 958 16-05-2008 04:37 PM
Last Post: ivenms
  Using iframes with javascript godkillah 0 1,947 26-01-2008 06:19 AM
Last Post: godkillah
  The JavaScript that Randomly Select the Quotes ivenms 9 722 29-09-2007 01:46 AM
Last Post: godkillah
Rolleyes JavaScript Redirection ivenms 0 693 15-09-2006 03:21 AM
Last Post: ivenms
Big Grin JavaScript Browser Detection ivenms 0 877 15-09-2006 03:20 AM
Last Post: ivenms

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites
Rate This Thread:

Forum Jump:

Sign In to Remove Ads

Download 1000's of web templates. Unlimited access!
World's Best Web Hosting
Resources

Recommended Sites:



Visit our Sponsors!

Current time: 06-01-2009, 11:10 PM


Copyright © 2002-2009 MyBB Group
Powered By MyBB