Here are 10 free java scripts and code snippets for you to use on your site
1. Bookmark this Page - This script allows your visitors to bookmark your page with one click of your mouse.
In the script below:
CHANGE var txt from (Bookmark This Page!) to the text you wish to have appear on your page for the bookmark link. Onmouseover your text will also appear in the status bar,
CHANGE var url from http://www.superaffiliatehandbook.com to the url you want to have bookmarked. Use the full address of the page!
CHANGE var who from Super Affiliate Handbook to the title that you want the bookmark to show when the user bookmarks your site.
INSERT the script in your page where you want the Bookmark This Page! link to appear.
<SCRIPT LANGUAGE="JavaScript">
var txt = "Bookmark This Page!";
var url = "http://www.superaffiliatehandbook.com";
var who = "Super Affiliate Handbook";
var ver = navigator.appName;
var num = parselnt(navigator.appVersion);
if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) { document.write('<A
HREF="javascript:window.external.AddFavorite(url,who);" '); document.write('onMouseOver=" window.status='); document.write("txt; return true "); document.write('"onMouseOut=" window.status='); document.write("' '; return true "); document.write('">'+ txt + '</a>'); }else{
document.write(txt); }
2. Date & Future Date - Place this code on your page where you wish the current date to appear.
You can also change the bolded "0" below, to another number to have a future date displayed. For example, if you wish to make a time-limited offer such as 'Buy before midnight (2 days from now)", you'd replace the "0" in the formula below with the number "2".
<script type="text/javascript"> var weekday=new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") var monthname=new
Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var todayInMS = today.getTime()
var inthreedays = todayInMS + (60 * 60 * 24 * 0 * 1000) // edit the 0 to change the number of days var newdate = new Date(inthreedays) document.write(weekday[newdate.getDay()] + ", ") document.write(monthname[newdate.getMonth()] + " ") document.write(newdate.getDate() + " ") document.write(newdate.getFullYear()) </script>
3. Make Homepage - Gives your visitors the option of making YOUR site THEIR homepage. Replace the bolded text with your own information and place the script where you wish the link to appear.
<SCRIPT LANGUAGE="JavaScript"> <!—Begin
// If Internet Explorer, use automatic link if (document.all){
document.write('<A HREF="javascript:history.go(0);"
onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http: //superaffiliatehandbook.com\');">');
document.write('Click Here To Make Us Your Homepage</a>');
// If Netscape 6, tell user to drag link onto Home button else if (document.getElementById){
document.write('<a href="http://superaffiliatehandbook.com">Drag this link onto your Home button to make this your Home Page.</a>');
// For Netscape 4 or lower, give instructions to set Home Page else if (document.layers){
document.write('<b>Make this site your home page:</b><br>- Go to <b>Preferences</b> in the <B>Edit</B> Menu.<br>- Choose <b>Navigator</b> from the list on the left.<br>- Click on the
<b>"Use Current Page"</b> button.'); }
// For any other browser, display instructions else {
document.write('<b>Make this site your home page:</b><br>- Go to <b>Preferences</b> in the <B>Edit</B> Menu.<br>- Choose <b>Navigator</b> from the list on the left.<br>- Click on the
<b>"Use Current Page"</b> button.'); }
4. Hide Status Bar - This is a cheap way to temporarily stop 'nosey-Parkers' from seeing your affiliate link coding. However, it's not very effective and tends to upset visitors when their browser window suddenly changes appearance.
<script>
function hidestatus(){ window.status=''
return true }
if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
document.onmouseover=hidestatus document.onmouseout=hidestatus
5. OnMouseOver - This code places text of your choosing in the status bar when visitors cursor over the link.
If text is placed between the quotations following onMouseOut="window.status='', the status bar will display that text until the visitor places his cursor over the next link.
<a href="http://www.one-and-only.com/index.htm?AssociateID=6486" onMouseOver="window.status='One and Only'; return true " onMouseOut="window.status=''; return true ">One and Only</a>
6. Open a New Window - This snippet will open a "new" window without closing the current window when the link is clicked. So, when the visitor closes the "new"
window, the current window (hopefully yours) will still be open underneath it. <a href="http://sage-hearts.com" target="new">
7. Pop-Up - On Entrance - Opens the specified URL into a pop-up window when a visitor first enters a Web page.
PASTE the following bold script in between the <head> </head> tags on the page you want the pop up window to launch from. This particular script will open http://rosalindgardner.com, but you can change it to anything you like.
<script language="JavaScript" for="window" event="onload()"> <! —
window.open("http://rosalindgardner.com", "vb", "scrollbars,resizable,height=600,width=800")
8. Pop-Up - On Exit - Opens the specified URL into a pop-up (pop-under) window when a visitor exits a Web page.
PASTE the following script in between the <HEAD> </HEAD> tags on the page you want the pop up window to launch from when your visitor leaves the page. This particular script opens a page named "popexit.html", but you can name it anything you like.
<script language="JavaScript" for="window" event="onunload()"> window.open("popexit.html"
"scrollbars=no,resizable=no,height=300,width=300") </script>
Next, paste the following bolded code into the <body onunload="xit()"> tag on the same page.
9. Pop-Up - Timed - The following pop-up script opens after a specified number of seconds and closes (if you want it to) after a specified amount of time.
Place the script between the <Head> </Head> on your web page.
To set the time delay before opening, change '40' in 'delay = 40' to the number of seconds of your choosing.
Likewise, if you wish the pop-up to close, change '600' in 'closetime = 600' to however many seconds you prefer.
<script language=JavaScript>
<!—Begin closetime = 600; // Close window after 600 number of seconds?
// 0 = do not close, anything else = number of seconds function Start(URL, WIDTH, HEIGHT) {
windowprops = "left=50,top=50,width=" + WIDTH + ",height=" + HEIGHT;
preview = window.open(URL, "preview", windowprops);
if (closetime) setTimeout("preview.close();", closetime*600); }
function doPopup() { url = "countdown.html";
width = 320; // width of window in pixels height = 650; // height of window in pixels delay = 40; // time in seconds before popup opens timer = setTimeout("Start(url, width, height)", delay*1000); }
Add the following bolded code in the first <Body> tag to make the script above work properly.
<BODY onload=doPopup();>
10. Right-Click Disabled - This script is used to disable the right-click feature on your pages so that nosey webmasters won't be able to see the actual destination URL behind your link.
More knowledgeable webmasters will simply proceed from the "right click disabled" notice to "View Source", but the script may stop a few snoopers from removing your affiliate ID from the link.
To disable the right-click feature, place the following script in the Head of your page.
<script language="Javascript1.2">
// Set the message for the alert box am = "This function is disabled!";
// do not edit below this line // ===========================
bV = parseInt(navigator.appVersion) bNS = navigator.appName=="Netscape"
bIE = navigator.appName=="Microsoft Internet Explorer"
function nrc(e) {
alert(am)
return false
} else if (bIE && (event.button >1)) { alert(am)
return false; }
document.onmousedown = nrc;
if (document.layers) window.captureEvents(Event.MOUSEDOWN); if (bNS && bV<5) window.onmousedown = nrc;
Continue reading here: Merchant Copy and Sales Tools
Was this article helpful?