Is it possible to grab the full url into my "email a friend" script along with the body text?
<INPUT TYPE="image" src="fun2.gif" border=0 value="grab" name="grab" alt="Email a Friend This Page!" onClick="parent.location='mailto:friends@email-here.com?subject=Check out this Website&body=Hello, I found a great web page at window.location'">
<a href="mailto:friends@email-here.com?subject=Check out this Website&body=Hello, I found a great web page at window.location.href">
<img src"fun2.gif" border=0 value="grab" name="grab" alt="Email a Friend This Page!" />
</a>
<a href="javascript:window.location='mailto:friends@email-here.com?subject=Check out this Website&body=Hello, I found a great web page at ' + window.location.href">
<img src"fun2.gif" border=0 value="grab" name="grab" alt="Email a Friend This Page!" />
</a>
<a href="#" onclick="window.location='mailto:friends@email-here.com?subject=Check out this Website&body=Hello, I found a great web page at ' + window.location.href">
<img src"fun2.gif" border=0 value="grab" name="grab" alt="Email a Friend This Page!" />
</a>
When the URL has an "&" in it everything after this is being stripped off. Any idea on retaining the rest of the url in these cases? I guess it could be a limitation of the browser...
<a href="#" onclick="window.location='mailto:friends@email-here.com?subject=Check out this Website&body=Hello, I found a great web page at ' + window.location.href + window.location.search"><img src"fun2.gif" border=0 value="grab" name="grab" alt="Email a Friend This Page!" /></a>
You need to encode the text using URL safe characters:
Code:
function emailPage() {
var messageText = 'Hello, I found a great web page at ' + window.location;
var subjectText = 'Check out this Website';
var email = prompt("Enter your friend's email address:", 'email@address.com');
window.location = 'mailto:' + email +
'?subject=' + encodeURIComponent(subjectText) +
'&body=' + encodeURIComponent(messageText);
}
Then to use this function:
HTML Code:
<a href="#" onclick="emailPage(); return false;">Email This Page!</a>
Last edited by toicontien; 07-20-2007 at 05:19 PM.
Bookmarks