/    Sign up×
Community /Pin to ProfileBookmark

Send this link by e-mail Problem!!

The script below sends the link of the current page in an e-mail. It works fine when there is a URL with normal characters.

The problem is the page (php) uses ampersands in the URL, and it kills the creation of the link once it hits the first & in the string
(http://www.domain.com/index.php?&direction=0&order=&directory=hank/toy)

The script is below. What can I add to get the ampersand problem fixed so the complete URL gets picked up by the script and transfered to the e-mail as intended?


————————————-

<!– Begin E-Mail-This-Page Script //–>
<form name=”eMailer”>
E-MAIL THIS LINK
<br>
Enter recipient’s e-mail:
<br>
<input type=”text” name=”address” size=”25″>
<br>
<input type=”button” value=”Send this URL” onClick=”mailThisUrl();”>
</form>

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 = “I thought this 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=”+document.title+” “+u;
}
}
</script>
<!– End E-Mail-This-Page Script //–>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @aram spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...