Peter said:
I'm building a website and I want to add a script that allows a
reader to send to an msn buddy by clicking an icon. Is there such a
script available?
Do you want to send a message suggesting your website to the named friend?
The following will do this. Modify it if you want to do something slightly
different
Add to extenal.js
//-----------------
function checkEmailAddress(field)
{
// the following expression in () after 'match' must be all on one
line...
if (field.value.match
(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi))
return true
else
{ alert('Please enter a valid e-mail address.')
field.focus()
field.select()
return false }
}
//-------------------------------
function mailThisUrl()
{
var subj = "I thought this might interest you..."
var text = "Here is an interesting Website: "
var content = new Array()
content[0] = "mailto:"
content[1] = document.eMailer.address.value
content[2] = "?subject="
content[3] = subj
content[4] = "&body="
content[5] = text
content[6] = parent.document.title
content[7] = " ("
content[8] = parent.location
content[9] = ")"
content = content.join("")
if (checkEmailAddress(document.eMailer.address))
window.location = content
}
//-------------------------------
Add to <head>:
<script type="text/javascript" src="scripts/external.js"></script>
Add to <body>:
<form name="eMailer" action="">
<b>E-Mail this link to a friend</b><br />
Enter recipient's e-mail:<br />
<input type="text" name="address" size="30" /><br />
<input type="button" value="Send this URL" onclick="mailThisUrl()" />
</form>
It works in IE6. Should be O.K. for other browsers.