Wy╢lij adres znajomemu 2


Niniejszy skrypt dzia│a podobnie jak skrypt Wy╢lij adres znajomemu, ale nieco bardziej elegancko. Po podaniu adresu odbiorcy w temacie listu pojawia siΩ uzasadnienie (S▒dzΩ, ┐e to interesuj▒cy adres), za╢ w ciele listu zawarto╢µ pola Title strony i jej adres. Skrypt sprawdza tak┐e, czy pole adresu pocztowego jest poprawnie wype│nione.

Wy╢lij adres znajomemu

Podaj adres E-mail:

Skopiuj przyk│adowy kod.


<!-- Begin E-Mail-This-Page Script //-->
<form name="eMailer">
Wy╢lij adres znajomemu
<br><br>
Podaj adres E-mail:
<br>
<input type="text" name="address" size="25">
<br>
<input type="button" value="Prze╢lij ten URL" onClick="mailThisUrl();">
</form>

<script language="JavaScript1.2">
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header

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 = window.location;
m = "S▒dzΩ, ┐e to interesuj▒cy adres...";
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="+document.title+" "+u;
   }
}
</script>
<!-- End E-Mail-This-Page Script //-->