On The Insider: Jennifer Garner Restrains Stalker

Stupid Web Tricks: Add alerts to your site

Tags: Guest Contributor

  • Save
  • Print
  • Recommend
  • 0

Takeaway: Add alerts to your site in a snap. Use them to provide extra information to users or just to surprise them with jokes.

Click here for our complete list of Stupid Web Tricks.

You may want to provide visitors to your site with extra information at each turn. Or you may want to surprise them with a clever joke or insight as they move from page to page or use a form button. Whether or not your visitors want to be surprised this way is another question. Regardless, it's a snap to add alerts to your site.

Step One
Paste this code into the <HEAD> of your document:

<SCRIPT language="javascript">
<!-- hide javascript

function showAlert () {
   alert ("Your alert here");
   }

// done hiding -->
</SCRIPT>

Step Two
Call the showAlert() function from a hyperlink:

<A href="anotherpage.html" onClick="showAlert()">Hyperlinked word or image

When users click that link, they will see a dialog box with your message in it. Closing the box will send them to the URL.

To add an alert to form buttons, just insert the same onClick="showAlert()" to the <INPUT> tag of the button, like so:

<INPUT type=button value="Submit" onClick="showAlert()">

  • Save
  • Print
  • Recommend
  • 0

What do you think?

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET
advertisement
Click Here