473,386 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 6232
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Arpan | last post by:
A link has the following URL: <a href="Page1.asp?cname=<%= Request.QueryString("cname") %>&cadd1=<%= Request.QueryString("cadd1") %>&cadd2=<%= Request.QueryString("cadd2") %>&cplace=<%=...
13
by: darrel | last post by:
I am creating a querystring to look like this: form_edit.aspx?collectionID=25&amp;confirmationMessage=New+form+entry+saved Note that I'm escaping the ampersand. However, I can't grab the...
1
by: apiringmvp | last post by:
I am trying to post a large amount of data from an XmlSerialized Arraylist that is converted into a string of hex values. When I pass it to a querystring sometimes its gets truncated. Is there...
2
by: Ryan | last post by:
Hi. I am trying to encrypt some data being passed between two aspx pages using querystring. I have tried bith DES and Rijndael and have run across the following problem. After either provider...
2
by: Larry | last post by:
I am hoping there is a way to encode the querystring part of a URL reached from a hyperlink that will cause the Request to not drop the info after the # in the URL string. Any clues or links to...
6
by: Mehdi | last post by:
Hi, I get the following URL on page load: http://www.server1.com?RedirectUrl=http://www.server2.com?id=777 So QueryString will return (after cleaning up via URL Encode/decode) :...
3
by: Dariusz Tomon | last post by:
Hi My problem is like that: I'm trying to pass values branza and jezyk in querysting: http://localhost/euroadres/pokazbranza.aspx?branza=transport lotniczy&jezyk=1 Branza is type...
4
by: | last post by:
Hi all, If I am reading this right, then the querystring parameters must be "&amp;" and not "&". However, IIS 6.0 and asp.net request.querystring fails to capture the values if "&amp;" is specified....
3
by: Elroyskimms | last post by:
I have to encode an address which contains an ampersand (&) into a URL with various querystring parameters. The following code works fine: URLString = "www.myserver.com?AD1=" &...
2
by: subbusuresh | last post by:
hi, Any one can help me. <asp:GridView ID="grvDCList" runat="server" AutoGenerateColumns="False" > <Columns> <asp:HyperLinkField HeaderText="DC Number" DataNavigateUrlFields="Code" ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.