By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,422 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,422 IT Pros & Developers. It's quick & easy.

Encode a URL to fit into a querystring

P: n/a
Hi Gang,

I need to know the javascript syntax to encode a URL to fit into a
querystring. Basically I want to pass the URL of the current web page
as the subject of an e-mail so it'd be something like:

var email_link = "<a href=\"mailto:wh*****@wherever.com?subject=" +
document.URL + "\">";
document.write(email_link);

Thanks so much,
Christian Blackburn

Jun 13 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Christian Blackburn wrote:
I need to know the javascript syntax to encode a URL to fit into a
querystring.


var o1 = '?&%=';
var o2 = escape(o1);
alert(o2);

--
Bart

Jun 13 '06 #2

P: n/a

Christian Blackburn wrote:
Hi Gang,

I need to know the javascript syntax to encode a URL to fit into a
querystring. Basically I want to pass the URL of the current web page
as the subject of an e-mail so it'd be something like:

var email_link = "<a href=\"mailto:wh*****@wherever.com?subject=" +
document.URL + "\">";
document.write(email_link);

Thanks so much,
Christian Blackburn


I use http://javascript-library.blogdrive.com/archive/17.html

function esc(s){return
window.encodeURIComponent?encodeURIComponent(s):es cape(s)}
var email_link = "<a href=\"mailto:wh*****@wherever.com?subject=" +
esc(document.URL) + "\">";
document.write(email_link);

Jun 13 '06 #3

P: n/a
Hi Guys,

Thank you both for your help. The escape() command worked perfectly.

Cheers,
Christian

Jun 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.