Javascript Tell-a-Friend Script

Navigation

Sponsors

Javascript Tell-a-Friend Script

Save this to Del.icio.us

This tutorial will teach you how to setup a tell-a-friend section on your site. This can be very useful in marketing your site.


Select all (Ctrl + A) the text script INSIDE of this text box directly below and copy it to your clipboard (Ctrl + C).

Open a your webpage that you want your tell a friend email box to appear on, in a program such as Wordpad or Notepad and paste the above text (Ctrl + V) in between the <HEAD> Tags of the document.

The head of your webpage should now look like the code directly below. Edit the RED text only to reflect your information. In the email body fields. You must use " " to signify a line break. Do not make your message over 30 characters.

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin

var initialsubj="Hey buddy, take a look at this"
var initialmsg="Hi: You should check out this site: "
+window.location
var good;
function checkEmailAddress(field) {

var goodEmail =
field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|
(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum
)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
if (goodEmail) {
good = true;
}
else {
alert('Please enter a valid address.');
field.focus();
field.select();
good = false;
}
}
u = window.location;
function mailThisUrl() {
good = false
checkEmailAddress(document.eMailer.email);
if (good) {

//window.location =
"mailto:"+document.eMailer.email.value+"?
subject="+initialsubj+"&body="+document.title+"
"+u;
window.location =
"mailto:"+document.eMailer.email.value+"?
subject="+initialsubj+"&body="+initialmsg
}
}
// End -->
</script>

</HEAD>

For the above code to work, you will need to add a form to the webpage where visitors can enter their friends email address:

Select all (Ctrl + A) the text script INSIDE of this text box directly below and copy it to your clipboard (Ctrl + C).

Paste the above form code in your webpage where you want the form to appear in between the <body> </body> tags of your HTML page...

After you have embedded the <Head> script into your page, and added the form within the <body> tags you are ready to upload your pages!


[ Back to Website Tools and Tutorials ]


| Forums | Search | Donate | Links | Contact | Scripts | Templates |
Copyright © 2008 SiteToolCenter.com

Website Design

Best Viewed With Mozilla FireFox