469,270 Members | 1,763 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Encode a URL to fit into a querystring

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
3 6088
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

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

Similar topics

3 posts views Thread by Arpan | last post: by
1 post views Thread by apiringmvp | last post: by
2 posts views Thread by Ryan | last post: by
3 posts views Thread by Dariusz Tomon | last post: by
4 posts views Thread by | last post: by
3 posts views Thread by Elroyskimms | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.