I have an Email a Friend script for a website i work on but there are some problems with the encoding.
The Javascript opens the users email programme with a link to the refering page, but the page titles are in the URL's of each page and they are not being handled correctly i.e. when the email is recieved, the link goes to a 404 page as the punctuation in the title isnt converted correctly.
The problem is the punctuation in the page title inside the URL:
whatever/mim_forums_thread.htm?masterID=224&forumID=262&startPos=0&title=<b>Emails%20&%20Alerts!?!?!</b>
Is there a way that I can encode just this bit &title=<b>Emails%20&%20Alerts!?!?! without the rest of the URL being encoded? Some of the page titles have various bits of punctuation like ? . , ; " ... ??!! etc in them that need converting so they can be clicked from an email.
Any help is appreciated!!!
Adele x
The Javascript opens the users email programme with a link to the refering page, but the page titles are in the URL's of each page and they are not being handled correctly i.e. when the email is recieved, the link goes to a 404 page as the punctuation in the title isnt converted correctly.
The problem is the punctuation in the page title inside the URL:
whatever/mim_forums_thread.htm?masterID=224&forumID=262&startPos=0&title=<b>Emails%20&%20Alerts!?!?!</b>
Is there a way that I can encode just this bit &title=<b>Emails%20&%20Alerts!?!?! without the rest of the URL being encoded? Some of the page titles have various bits of punctuation like ? . , ; " ... ??!! etc in them that need converting so they can be clicked from an email.
Any help is appreciated!!!
Adele x
Code:
<script type='text/javascript' language='JavaScript'>
function jsMailThisUrl()
{
var email_subject = 'Check out this topic';
var email_body = 'I found this topic and thought you might be interested: ';
//var page_url = window.self.location.href.split( '?' )[0];
var page_url=window.location.href;
//page_url = page_url + '';
var page_url = page_url.replace("-admin", "-user");
var page_url = page_url.replace("message-admin", "thread");
var page_url = page_url.replace("<b>", "");
var page_url = page_url.replace("</b>", "");
var page_url = page_url.replace(/ /g, "%20
var field = document.email_friend_script.address;
window.location = 'mailto:' + field.value + '?subject=' +
escape( email_subject ) + '&body=' +
escape( email_body + page_url + '\n\n');
}
</script>