bisnis online, jual beli online, sistem pembayaran, pembayaran online, bisnis online
Home » » Useful Javascript Code Examples

Useful Javascript Code Examples

Written By Supriadi on Monday, April 30, 2012 | 9:29 PM

Below you'll find handy Javascript code examples for modifying text in the status bar display, preventing your site from being framed, protecting your email address, creating image rollovers with Javascript onMouseOver and more.
All you need to do is copy and paste them directly into your HTML source code.



Change Link Descriptions Shown In The Status Bar.

Add the following code to your links:
onMouseOver="window.status='Your Text Here.'; return true;"
Your link should then look something like this:
<A href="http://www.nowsell.com" onMouseOver="window.status='A Great place to Learn!'; return true;">NowSell.com</A>

Set The Default Text In The Status Bar.

Add the following code to your <BODY> tag:
OnLoad="window.defaultStatus='Your Message here';"
Your <BODY> tag should then look something like this:
<BODY bgcolor="#ffffff" text="#000000" link="#3300ff" alink="#ffff00" vlink="#3399cc" OnLoad="window.defaultStatus='Your Message here';">

Change An Image Link When The Mouse Cursor Is Moved Over It.

Use the following syntax:
<A href="http://www.nowsell.com" onMouseOver = "document.imagename.src='imagename_on.gif';return false;" onMouseOut = "document.imagename.src='imagename_off.gif';return false;">
<img src="imagename_off.gif" name="imagename" border="0">
</a>
Replace "http://www.nowsell.com" with the URL of the link and 'imagename' with any name you want.

Prevent anyone linking to your pages from within a frame on their site.

Use the following script between the <HEAD> and </HEAD> tags:
<SCRIPT>
if (self != top)
top.location = self.location
</SCRIPT>
The script checks if the page is being loaded into the original window (top). Whenever someone visits the page trapped in a frame, it will reload to fill the original browser window.
OR
Add the JavaScript code below into your <BODY> tag:
onLoad="if (self != top) top.location = self.location"
Your <BODY> tag should then look something like this:
<BODY bgcolor="#ffffff" text="#000000" link="#3300ff" alink="#ffff00" vlink="#3399cc" onLoad="if (self != top) top.location = self.location">

Prevent Spam Robots From Harvesting Your E-Mail Address On A Web Page.

Format a 'mailto' as follows:
mailto:%20yourname@yourdomain.com
It works when someone clicks on it, but when the robots pick it up they end up with an invalid address.
Or using a simple script:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
user = "username";
site = "yoursite.com";

document.write('<a href=\"mailto:' + user + '@' + site + '\">');
document.write(user + '@' + site + '</a>');
/ End -->
</SCRIPT>

Make A "Previous Page" Link That Acts Like A Browser's Back Button.

Use the following as your link:
href="javascript:history.back()"
e.g.
<A href="javascript:history.back()">Previous Page</A>

Html Colors That Can Be Specified By A Name.

The full set of sixteen supported colornames:
aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white and yellow.
e.g. <FONT face="arial" color="blue">This text is blue</FONT>
Share this article :

0 komentar:

Post a Comment



 
Support : Your Link | Your Link | Your Link
Copyright © 2013. Catatan Online Supri7 - All Rights Reserved
Template Created by Creating Website Modified by Cara Gampang
Proudly powered by Blogger