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. You are encouraged to play with the variables in these scripts to learn more about how they work.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
Bookmark Page
Paste this snippet in the body of your document where you want the link to appear. Change the script in Red.
This script only works for IE5+ browsers. Other browsers will not see anything.
--------------------------------------------------------------------------------
Make Your Page Users Start Page
This script will let users make your page the start up page for their browser. Paste this snippet in the body of your document where you want the link to appear.
This script only works for IE5+ browsers. Other browsers will not see anything. Just change the http://www.mysite.com to the URL of your page.
--------------------------------------------------------------------------------
No Frills Popup
Just copy and paste this into the head of your document changing the script in Red.
--------------------------------------------------------------------------------
Close Window With A Button
Add this short snippet to the body of your popup windows so that they can be closed easily.
(See "Jazzing Up Your Forms" at the bottom of this page for ideas to make your button look more stylish.)
--------------------------------------------------------------------------------
Close Window With A Link
Add this short snippet to the body of your popup windows so that they can be closed easily.
--------------------------------------------------------------------------------
Updating Copyright Notice
This copyright notice places 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.
Example: © 2013 all rights reserved
--------------------------------------------------------------------------------
Date Last Modified.
Use this script to show when your page was last modified.
Example: Last modified 01/06/2013 14:29:38
--------------------------------------------------------------------------------
Back to Top of Page link
Use this script if you have a long page.
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.
Example: 6 January 2013
--------------------------------------------------------------------------------
Document Last Modified (a more readable version)
Insert this code in your document where you want the page last modified date to appear.
Example: Last Modified: Sunday 6th January, 2013
--------------------------------------------------------------------------------
Break Out Of Frames
Use this script in between the <head></head> tags of your document to automatically bust out of other peoples frames.
Of course if your own site is a framed site then this could cause an endless loop and your pages will not be viewable.
--------------------------------------------------------------------------------
Highlight the Background of Text
Change the color of the text as well.
You could even highlight the background of a whole paragraph using...
The possibilities are almost endless.
--------------------------------------------------------------------------------
Add a Title Attribute to Text Links
This will popup a small description like that used in "alt" for your graphics.
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.
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 your site, search box may have a slightly different look.
Place this script in the head of any document that you want to be maximised.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.
Include the following onload event call in the body tag. This stops the page being saved until it is fully loaded.
To call the script from the page and activate the SaveAs dialog, insert a link in the page like this:
--------------------------------------------------------------------------------
Show users where on your site they currently located.
Example: You are here: > C: > Users > DELL > AppData > Local > Temp > e > 88786-030911-065434-00.a2k > quick.html
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.
--------------------------------------------------------------------------------
Default Statusbar Message.
--------------------------------------------------------------------------------
to be continued.............
Source & read more http://master-land.net/t/37060/quick-copy-and-paste-scripts.html
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. You are encouraged to play with the variables in these scripts to learn more about how they work.
--------------------------------------------------------------------------------
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.
Code:
<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.
Code:
<a href='javascript:;' onClick='window.print();return false'>Print this page.</a>
--------------------------------------------------------------------------------
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.
Code:
<script LANGUAGE="JavaScript">
<!--
function click() {
if (event.button==2) {
alert('[color=red]Right Click Option Not Available![/color]');
}
}
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.
Code:
<!--[if IE]>
<a href="javascript:window.external.AddFavorite('http://www.yoursite.com/', 'My Site Title');">Bookmark This Site!</a>
<![endif]-->
This script only works for IE5+ browsers. Other browsers will not see anything.
--------------------------------------------------------------------------------
Make Your Page Users Start Page
This script will let users make your page the start up page for their browser. Paste this snippet in the body of your document where you want the link to appear.
Code:
<!--[if IE]>
<a HREF style="cursor:hand;" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.mysite.com');">Make this page your home page!</a>
<![endif]-->
This script only works for IE5+ browsers. Other browsers will not see anything. Just change the http://www.mysite.com to the URL of your page.
--------------------------------------------------------------------------------
No Frills Popup
Just copy and paste this into the head of your document changing the script in Red.
Code:
<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.
Code:
<form>
<input type="button" value="Close Window" onClick="window.close()">
</form>
(See "Jazzing Up Your Forms" at the bottom of this page for ideas to make your button look more stylish.)
--------------------------------------------------------------------------------
Close Window With A Link
Add this short snippet to the body of your popup windows so that they can be closed easily.
Code:
<a href="javascript: self.close()">Close Window</a>
--------------------------------------------------------------------------------
Updating Copyright Notice
This copyright notice places 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.
Code:
<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: © 2013 all rights reserved
--------------------------------------------------------------------------------
Date Last Modified.
Use this script to show when your page was last modified.
Code:
<script language="javascript">
<!--
document.write('Last modified '+document.lastModified);
//-->
</script>
Example: Last modified 01/06/2013 14:29:38
--------------------------------------------------------------------------------
Back to Top of Page link
Use this script if you have a long page.
Code:
<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.
Code:
<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: 6 January 2013
--------------------------------------------------------------------------------
Document Last Modified (a more readable version)
Insert this code in your document where you want the page last modified date to appear.
Code:
<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: Last Modified: Sunday 6th January, 2013
--------------------------------------------------------------------------------
Break Out Of Frames
Use this script in between the <head></head> tags of your document to automatically bust out of other peoples frames.
Code:
<script language="JavaScript">
<!--
if (window != top) top.location.href = location.href;
//-->
</script>
Of course if your own site is a framed site then this could cause an endless loop and your pages will not be viewable.
--------------------------------------------------------------------------------
Highlight the Background of Text
Code:
<span style="background-color:ff0000;">Put Your Text Here</span>
Change the color of the text as well.
Code:
<span style="background-color:ff0000; color: 0000ff">Put Your Text Here</span>
You could even highlight the background of a whole paragraph using...
Code:
<div style="background-color: CDFFB2"> Your Text Goes Here </div>
The possibilities are almost endless.
--------------------------------------------------------------------------------
Add a Title Attribute to Text Links
This will popup a small description like that used in "alt" for your graphics.
Code:
<A HREF="http://daivietpda.vn" TITLE="Great Website Tools!">Your Text Here</a>
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.
Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Super Search Box © 2013 RACKHOST.INFO
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>
Due to the style sheets used in your site, search box may have a slightly different look.
Place this script in the head of any document that you want to be maximised.
Code:
<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.
Code:
<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.
Code:
<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.
Code:
<body onload="isReady=true">
To call the script from the page and activate the SaveAs dialog, insert a link in the page like this:
Code:
<a href="javascript:doSaveAs()"> Click Here To Save This Page </a>
--------------------------------------------------------------------------------
Show users where on your site they currently located.
Example: You are here: > C: > Users > DELL > AppData > Local > Temp > e > 88786-030911-065434-00.a2k > quick.html
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.
Code:
<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.
Code:
<BODY OnLoad="window.defaultStatus='Put Your Message Here!';">
--------------------------------------------------------------------------------
to be continued.............
Source & read more http://master-land.net/t/37060/quick-copy-and-paste-scripts.html