Quick Copy and Paste Scripts.

These javascript snippets can be cut and pasted into your page with little or no alteration. To copy the scripts highlight them with your mouse and then press the [Ctrl] & [C] keys simultaneously to copy them to the clipboard. The script can then be pasted into your application.


Microsoft Smart Tags
Windows XP and IE6+ technology allows Microsoft to insert links in your Web Pages without your knowledge or permission. Luckily this function can be disabled by pasting the following tag into the head of your document.

<META NAME="MSSmartTagsPreventParsing" content="true">

Automatic Print Script
This is a super-easy little script that you can use to form an automatic print-page link on your site. Just insert this script where you want the link to display and your visitors can choose to print the page they are viewing.

<a href='javascript:;' onClick='window.print();return false'>Print this page.</a>

This is an example. Print this page.


No Right Click
Place this script between the head tags. You can change the wording in Red. Just be aware that these "no right click" type scripts only deter the inexperienced user. There are many ways around them.

<script LANGUAGE="JavaScript">
<!--
function click() {
if (event.button==2) {
alert('Right Click Option Not Available!');
}
}
document.onmousedown=click
// -->
</script>


Bookmark Page
Paste this snippet in the body of your document where you want the link to appear. Change the script in Red.

<a href="javascript:window.external.AddFavorite('http://www.yoursite.com/', 'My Site Title');">Bookmark This Site!</a>

This script only works for IE5+ browsers.


No Frills Popup
Just copy and paste this into the head of your document changing the script in Red.

<SCRIPT language="JavaScript">
<!--
window.open('mypage.html');
// -->
</SCRIPT>


Close Window With A Button
Add this short snippet to the body of your popup windows so that they can be closed easily.

<form>
<input type="button" value="Close Window" onClick="window.close()">
</form>


Close Window With A Link
Add this short snippet to the body of your popup windows so that they can be closed easily.

<a href="javascript: self.close()">Close Window</a>


Updating Copyright Notice
This copyright notice palces the current year on the page so that copyright notices are always current. Once it's on your page there is no need to update the script.

<script language = 'JavaScript'>
<!--
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
var today = new Date();
var year = y2k(today.getYear());
document.write('© '+year+' all rights reserved');
//-->
</script>

Example


Date Last Modified.
Use this script to show when your page was last modified.

<script language="javascript">
<!--
document.write('Last modified '+document.lastModified);
//-->
</script>


Back to Top of Page link
Use this script if you have a long page.

<a href="javascript:window.scrollTo(0,0);">Back to top of page</a>

Example Back to top of page


Add the current date to your page.
This script will add the date in the form dd month yyyy (eg. 7 January 2000). Just copy and paste it into the document where you want it to appear.

<script language="JavaScript">
<!--
function makeArray() {
for (i = 0; i<makeArray.arguments.length; i++)
this[i + 1] = makeArray.arguments[i];
}
var months = new makeArray('January','February','March','April','May','June', 'July','August','September','October','November','December');
var date = new Date();
var day = date.getDate();
var month = date.getMonth() + 1;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
document.write(day + " " + months[month] + " " + year);
//-->
</script>

Example


Document Last Modified (a more readable version)
Insert this code in your document where you want the page last modified date to appear.

<script language = 'JavaScript'>
<!--
function makeArray0() {
for (i = 0; i<makeArray0.arguments.length; i++)
this[i] = makeArray0.arguments[i];
}
var days = new makeArray0("Sunday","Monday","Tuesday","Wednesday","Thursday" ,"Friday","Saturday");
var months = new makeArray0('January','February','March','April','May','June', 'July','August','September','October','November','December');
function nths(day) {
if (day == 1 || day == 21 || day == 31) return 'st';
if (day == 2 || day == 22) return 'nd';
if (day == 3 || day == 23) return 'rd';
return 'th';
}
function getCorrectedYear(year) {
year = year - 0;
if (year < 70) return (2000 + year);
if (year < 1900) return (1900 + year);
return year;
}
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
function padout(number) { return (number < 10) ? '0' + number : number; }
var last = document.lastModified;
var date = new Date(last);
var dateY2K = new Date(getCorrectedYear(date.getYear()),date.getMonth(),date.getDate());
document.write('Last Modified: '+ days[dateY2K.getDay()] + ' ' +
dateY2K.getDate() + nths(dateY2K.getDate()) + " " +
months[dateY2K.getMonth()] + ", " +
(y2k(dateY2K.getYear()))
);
//-->
</script>

Example


Break Out Of Frames
Use this script in between the <head></head> tags of your document to automatically bust out of other peoples frames.

<script language="JavaScript">
<!--
if (window != top) top.location.href = location.href;
//-->
</script>


Highlight the Background of Text

<span style="background-color:ff0000;">Put Your Text Here</span>


Add a Title Attribute to Text Links
This will popup a small description like that used in "alt" for your graphics.

<A HREF="http://www.sawpit.net" TITLE="Great Website Tools!">Your Text Here</a>

Hover your cursor over this link for an example.Sawpit.net Webmaster Tools


Add an internet search box to your site.
Your visitors will be able to search the WWW (via multiple search engines) and a KIDSAFE search engine (Yahooligans). Just copy and paste the following script into your document and you will have your visitors returning to your site every time they are looking for something on the WWW.

The Super Search Box will appear on your page just as the working copy does at the bottom of this page.

<SCRIPT LANGUAGE="JavaScript">
<!-- Super Search Box © 2000 www.sawpit.net
document.writeln('<TABLE CELLPADDING=\"0\" CELLSPACING=\"2\" width=\"230\" border=\"2\" bordercolor=\"#000000\" bgcolor=\"#ffffff\">');
document.writeln('<TR><TD width=\"100%\">');
document.writeln('<form method=\"GET\" action=\"http://s1.search66.com/cgi-bin/search.cgi\" target=\"_blank\">');
document.writeln('<DIV ALIGN=\"center\">');
document.writeln('<font size=\"-1\"><b>Internet search</b></font><BR> ');
document.writeln('<input type=\"text\" name=\"q\" size=\"32\"> <br>');
document.writeln('<input type=\"hidden\" name=\"c\" value=\"w\">');
document.writeln('<input type=\"hidden\" name=\"uf\" value=\"ON\">');
document.writeln('<input type=\"hidden\" name=\"st\" value=\"phrase\">');
document.writeln('<input type=\"hidden\" name=\"ss\" value=\"3\">');
document.writeln('<input type=\"submit\" value=\"Search\"> <INPUT TYPE=\"reset\" VALUE=\"Reset\"></div>');
document.writeln('</form>');
document.writeln('</TD></TR>');
document.writeln('<TR><TD valign=\"top\">');
document.writeln('<div align=\"center\">');
document.writeln('<FORM METHOD=GET action=\"http://search.yahooligans.com/search/ligans\" target=\"_blank\">');
document.writeln('<font size=\"-1\"><B>Kid safe search</B></font><BR>');
document.writeln('<INPUT type=\"text"\ size=\"32\" name=\"p\"><br>');
document.writeln('<INPUT type=\"submit\" value=\"Search\"> <INPUT TYPE=\"reset\" VALUE=\"Reset\"></form></div>');
document.writeln('</TD></TR>');
document.writeln('</table>');
//-->
</SCRIPT>

Page Formatting Note: The Super Search Box script generates a table that is 230 pixels wide. If you cannot fit it in a table cell on your existing page you may need to paste the code at the bottom of your page or, alternatively, on it's own page.


Due to the style sheets used in Webmaster Tools your search box may have a slightly different look.


Window Maximiser
Place this script in the head of any document that you want to be maximised.

<script language="Javascript">
<!--
window.moveTo(0,0)
window.resizeTo(screen.width,screen.height)
//-->
</script>


Keep Window In Focus
Use this code to make sure a window remains in focus, on top. Great for web site news or smaller popup windows that are easily shuffled under out of focus.

<body onblur="self.focus();">


Allow Users To Save Your Page To Their Hard Drive
IE4+ browsers have a function that allows you to call the SaveAs dialog to save a web page. The following script includes an alternate alert message for non-IE browsers.

Paste the following script in the head of of your document.

<script language="JavaScript">
<!--
var isReady = false;
function doSaveAs(){
if (document.execCommand){
if (isReady){document.execCommand("SaveAs");}
}else{
alert('Feature available only in Internet Exlorer 4.0 and later.');
}
}
//-->
</script>

Include the following onload event call in the body tag. This stops the page being saved until it is fully loaded.

<body onload="isReady=true">

To call the script from the page and activate the SaveAs dialog, insert a link in the page like this:

<a href="javascript:doSaveAs()"> Click Here To Save This Page </a>


Show users where on your site they currently located.

Example:

The results you get from a page on your hard drive will obviously be different to those from your web site.

Insert the following code in the body of each document where you want the information to appear. No code changes are necessary.

<script language="JavaScript">
<!--
thePath = '';
loc = '' +location.href;
paths = loc.substring(7).split('/');
for (i=0, n=paths.length;i<n;i++)
thePath += '> ' + paths[i] + ' ';
document.write('<font color="#ff0000"><b>You are here: ' +
thePath.substring(1)+'</b></font>');
//-->
</script>


Default Statusbar Message.

<BODY OnLoad="window.defaultStatus='Put Your Message Here!';">


Text Area Background

Give your form textarea a background. Just paste the script between the <head> </head> tags of your document. Change "mypic.gif" to the name of your graphic and change the hexidecimal color code to a contrasting color to the background graphic. Then just do your form as normal and set the text area to the size of the graphic with something like <TEXTAREA ROWS="20" COLS="60">


Copy and paste this script into the body of your document where you want the effect to appear. Then just change the code in RED eg. var message, the typingbasecolor and the typingtextcolor for a great effect. You can also change blinkspeed, fontface and fontsize to further personalise the script. The rest of the script should remain unchanged.

<script language="JavaScript1.2">
var message="EreNeT.NeT Eğlencenin Merkezi.."
var typingbasecolor="ececec"
var typingtextcolor="ff00ff"
var blinkspeed=100
var fontface="arial,geneva,helvetica"
var fontsize="5"
var n=0
if (document.all){
document.write('<font face="'+fontface+'" size="'+fontsize+'" color="'+typingbasecolor+'">')
for (m=0;m<message.length;m++)
document.write('<span id="typinglight">'+message.charAt(m)+'</span>')
document.write('</font>')
var tempref=document.all.typinglight
}
else
document.write(message)
function typing(){
if (n==0){
for (m=0;m<message.length;m++)
tempref[m].style.color=typingbasecolor
}
tempref[n].style.color=typingtextcolor
if (n<tempref.length-1)
n++
else{
n=0
clearInterval(blinking)
setTimeout("starttyping()",1500)
return
}
}
function starttyping(){
if (document.all)
blinking=setInterval("typing()",blinkspeed)
}
starttyping()
</script>


Background Fireworks.

Just copy and paste this script anywhere in the body of your document for a dynamic background effect. There is no need to change any code. It will work best with a dark background in your document.


Cross Browser Background Sound

Copy and paste this script into the body of your document. Just change the name of the mid file.

<SCRIPT LANGUAGE="JavaScript">
<!--
var MSIE=navigator.userAgent.indexOf("MSIE");
var NETS=navigator.userAgent.indexOf("Netscape");
var OPER=navigator.userAgent.indexOf("Opera");
if((MSIE>-1) || (OPER>-1)) {
document.write("<BGSOUND SRC=mysong.mid LOOP=INFINITE>");
} else {
document.write("<EMBED SRC=mysong.mid AUTOSTART=TRUE ");
document.write("HIDDEN=true VOLUME=100 LOOP=TRUE>");
}
//-->
</SCRIPT>


Simple Image Change For Time Of Day

This script will show an image of your choice depending on the viewers time. If it is between 6am and 6pm they get one image and if its between 6pm and 6am they get another. In the following example you will see a sun if it is between 6am and 6pm or a moon otherwise. Just change the URL for your images and paste the code where you want the image to appear. The script works on a 24 hour clock. You can change the hours (in red) to suit your needs. It will work best if the images are the same size.

<script language="javascript">
<!--
var cur= new Date()
var change=cur.getHours()
if ((change<18) && (change>=6))
document.write("<img src='sun.gif'>")
else
document.write("<img src='moon.gif'>")
//-->
</script>


WWW Jump Box

Give your visitors a jump box so that they can access anywhere on the WWW from your page.

<form name="jumpbox">
<input style="border-color: black; border-size: 2;" type="text" name="href" size="25" value="http://">
<input type="button" value="Go To" onClick="parent.location.href=document.jumpbox.href.value;">
</form>


Translate Your Site

Tap into the Google translation service and translate your site from English to German, French, Spanish, Portuguese or Italian.

<form name=goour action="http://translate.google.com/translate" target="_blank">
<input type="hidden" name="u" value="http://yoursite.com" target="_blank">
<select name=langpair>
<option value="en|es">to Spanish
<option value="en|fr">to French
<option value="en|de">to German
<option value="en|it">to Italian
<option value="en|pt">to Portuguese
</select>
<INPUT TYPE=hidden name=hl value=en>
<INPUT TYPE=hidden name=ie value=ISO-8859-1>
<INPUT TYPE=hidden name=oe value=ISO-8859-1>
<input type=hidden name=prev value="/language_tools">
<br>
<input type="submit" value="Translate Now">
</form>

The example below translates a page from the www.sawpit.net site