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.
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 //-->