shanuragu
09-08-2003, 02:20 AM
Hi
On my new site I am planning to introduce an option to allow the user to recommend my web site to any of their frieds.
I am achieving this by providing a text box to enter one of their friends email address & click a button "send the link" which opens an email box with the respective email id, subject as " I thought this page might interest you..." & in the body section I want to send my web site link - when clicked should take them to my web site.
The whole process is achieved through js. Here is the code.
<SCRIPT LANGUAGE="JavaScript">
<!--- Begin
var good;
function checkEmailAddress(field) {
// the following expression must be all on one line...
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail) {
good = true;
}
else {
alert('Please enter a valid e-mail address.');
field.focus();
field.select();
good = false;
}
}
u = "http://www.mywebsite.com";
m = "I thought this page might interest you...";
function mailThisUrl() {
good = false
checkEmailAddress(document.eMailer.address);
if (good) {
// the following expression must be all on one line...
window.location = "mailto:"+document.eMailer.address.value+"?subject="+m+"&body="+u+" ";
}
}
// End -->
</script>
e-mail this <font face="verdana, arial, helvetica, courier, courier new" size="-2"><b>mywebpage.com</b></font> page link to a friend
<br>
by entering a recipient's e-mail address
<br>
<input type="text" name="address" size="25">
<br>
<input type="button" value="then send the link!" onClick="mailThisUrl();">
I am successfully displaying the email box, & the link at the body , but unable to click the link & display my web site??
What is wrong with this code??? please help.
:confused:
On my new site I am planning to introduce an option to allow the user to recommend my web site to any of their frieds.
I am achieving this by providing a text box to enter one of their friends email address & click a button "send the link" which opens an email box with the respective email id, subject as " I thought this page might interest you..." & in the body section I want to send my web site link - when clicked should take them to my web site.
The whole process is achieved through js. Here is the code.
<SCRIPT LANGUAGE="JavaScript">
<!--- Begin
var good;
function checkEmailAddress(field) {
// the following expression must be all on one line...
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail) {
good = true;
}
else {
alert('Please enter a valid e-mail address.');
field.focus();
field.select();
good = false;
}
}
u = "http://www.mywebsite.com";
m = "I thought this page might interest you...";
function mailThisUrl() {
good = false
checkEmailAddress(document.eMailer.address);
if (good) {
// the following expression must be all on one line...
window.location = "mailto:"+document.eMailer.address.value+"?subject="+m+"&body="+u+" ";
}
}
// End -->
</script>
e-mail this <font face="verdana, arial, helvetica, courier, courier new" size="-2"><b>mywebpage.com</b></font> page link to a friend
<br>
by entering a recipient's e-mail address
<br>
<input type="text" name="address" size="25">
<br>
<input type="button" value="then send the link!" onClick="mailThisUrl();">
I am successfully displaying the email box, & the link at the body , but unable to click the link & display my web site??
What is wrong with this code??? please help.
:confused: