Free JavaScript Codes - Commercial Editions


These codes are offered at no charge for commercial and personal use, but are unsupported.

  1. Email Page URL
  2. Clear Text Box
  3. Select All Text Box
  4. Spam-Proof Java Script Email
  5. Accept Terms & Conditions
  6. Accept Terms & Conditions (Text link version)
  7. Form Box Counter
  8. Randomize Text / Images / Anything (new)
  9. Licence Information

Need a better or New hosting account? Join us today on Globlat.com
More Info...

1. Email Page URL

Allows visitors to recommend any web page throughout a site. The URL to the page is sent via the visitors email program.

Demo:

Recommend this Page to a Friend

Codes:

Insert between <HEAD> and </HEAD>

<SCRIPT language="JavaScript" type="text/javascript">
<!--
function emailink(){
window.location = "mailto:"+"?subject=Hi, this web page might interest you..." + "&body="+window.location.href;
}
//-->
</SCRIPT>

Insert this anywhere on the web page

<a href="javascript:emailink()">Recommend this Page to a Friend!</a>

 


2. Clear Text Box

Help your visitors fill-out a your form box by placing instructions in the box field. When the user clicks the field, the text instantly clears from the box. Also quite uniquely for this type of script, when the box is left empty and the user clicks elsewhere, the pre-set text returns.

Demo:

Codes:

Insert within your current form

<input type="text" size="30" name="box" value="Type your name here" onfocus="javascript:if(this.value=='Type your name here') {this.value='';}" onblur="javascript:if(this.value=='') {this.value='Type your name here'}">

 


3. Select All Text Box

Allows the user to Copy & Paste the contents of a text box.

Demo:


click to select code

Codes:

Insert between <HEAD> and </HEAD>

<SCRIPT language="JavaScript" type="text/javascript">
<!--
// Script Source: www.insighteye.com
function selectAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
}
//-->
</SCRIPT>

Insert this anywhere on the web page

<form name="name_a">
<textarea name="name_b" cols="28" rows="3">
free javascripts...
</textarea><br>
<a href="javascript:selectAll('name_a.name_b')">click
to select code</a>
</form>

Notes

<form name="name_a"> and <textarea name="name_b"> needs to match in the line: <a href="javascript:selectAll('name_a.name_b')">


4. Spam-Proof Email Script

Uses Java Script to present the email address thus does not actually store the address in the page HTML.

Codes:

Insert between <HEAD> and </HEAD>

<SCRIPT language="JavaScript" type="text/javascript">
<!--
// Script Source: www.insighteye.com
function EM085518756(a) {
RE = /^(.+)\#(.+)$/;
var launch = a.replace(RE,"mailto:$1@$2");
window.location = launch;
}
//-->
</SCRIPT>

Insert this anywhere on the web page:

<a href="javascript:EM085518756('info#yoursite.com')">e-mail us</a>

Notes

Change both instances of 'EM085518756' to any unique number/letter combination.


5. Accept Terms & Conditions

This Script requires the visitor/customer to accept your terms before proceeding to the next page.
Ideal for order-forms, age restricted content etc.

Demo:

I ACCEPT THE TERMS & CONDITIONS:

Codes:

Insert between <HEAD> and </HEAD>

<script language="JavaScript" type="text/javascript">
<!--
// Script Source: www.insighteye.com
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert("Please tick the box to continue");
return false;
}else
return true;
}
//-->
</script>

2:  Insert anywhere on the web page:

<form action="tc_yes.html" method="GET" onsubmit="return checkCheckBox(this)">
I accept: <input type="checkbox" value="0" name="agree">
<input type="submit" value="Continue">
<input type="button" value="Exit" onclick="document.location.href='index.html';">
</form>

Note:

If you receive error: "Method Not Allowed" then change the line method="POST" to method="GET"
The script works in both modes.

The destination for the Exit button code:

'document.location.href='index.html'

can be any page in your web site. We suggest your home page as the best choice.

The line:

"tc_yes.html"

should be the page your visitors are clicking too or a CGI script as appropriate.


6. Accept Terms & Conditions - Text Link Version

Same as above script but can be used with text links instead of a submit button.

Demo:

I ACCEPT THE TERMS & CONDITIONS:

Go To Product Page

Codes:

Insert between <HEAD> and </HEAD>

<script language="JavaScript" type="text/javascript">
<!--
// Script Source: www.insighteye.com
function checkCheckBoxAgree(c){
if (c.agree_text.checked == false )
{
alert("Please tick the box to continue");
return false;
}else
return true;
}
//-->
</script>

Insert this anywhere on the web page

<form name="agreeform" action="#">
I accept: <input name="agree_text" type="checkbox" value="0">
<a href="demo_tc_done.html" onclick="return checkCheckBoxAgree(document.forms['agreeform'])">

Notes

If you receive error: "Method Not Allowed" then change the line method="POST" to method="GET"
The script works in both modes.

The line:

"demo_tc_done.html"

should be the page your visitors are clicking to or a CGI script as appropriate.


7. Form Box Counter

If you have a form box that requires a certain amount of characters to be entered in the box, then this
script will give a count feature. A dialog box tells the user how many characters have been entered and
a warning if over the designated amount.

(Set for 10 characters maximum. Add 1 more character to see the effect.

Demo:

Codes:

Insert between <HEAD> and </HEAD>

<script language="JavaScript" type="text/javascript">
<!--
// Script Source: www.insighteye.com
function CheckSize(form, field) {
if (field ==1) {
Ctrl = form.test;
y = 30;
x = Ctrl.value.length;
}
if (x < y)
SendMsg (Ctrl, "OK - number of characters is: " + x); else
SendMsg (Ctrl, "Too Long - number of characters is: " + x);}
function SendMsg (Ctrl, PromptStr) { alert (PromptStr);
Ctrl.focus(); return;}
//-->
</script>

Insert this section within your current form:

<textarea rows="3" name="test" cols="26">1234</textarea>
<input onclick="CheckSize(this.form,1)" type="button" value="count">

Notes

This line:

Ctrl = form.test

needs to be the same name as the form box you wish to count --

<textarea rows="3" cols="26" name="test">


8. Randomize Text, Images, Etc

This script will randomize text, image ads or just about anything else you need.

Codes:

Insert this wherever you want the random item to display:

<script language="JavaScript" type="text/javascript">
<!-- // Script Source: www.insighteye.com
function randa() {
};
randa = new randa();
number = 0;

// keep adding these for more random items
randa[number++] = 'random item 1'
randa[number++] = 'random item 2'

increment = Math.floor(Math.random() * number);
document.write(randa[increment]);
//-->
</script>

 


LICENCE INFORMATION

These free Javascript codes are offered at no charge for commercial and personal use and are used entirely at your own risk. These scripts are copyright and may not be reproduced without permission. License for Free Use: Script source tags in these codes may not be removed in any circumstance. Liability and Warranty Disclaimer: All Java Script's are provided "as is" and without any warranties as to performance or merchantability, or any other warranties, whether expressed or implied. All scripts are supplied free but are unsupported. Do enjoy!


© 2008 Insight Eye Publishing

Home | Our New Globat Hosting Offers | The BOTW Directory | Contact Us

Valid XHTML 1.0 Transitional