Jason_Beaudoin
04-25-2003, 07:47 PM
Hello everyone!
I'm attempting to pass a URL string from Javascript to an ASP page, and because my string contains special characters (like é, è, à, ') I'm having to use the "escape" function to encode the characters so that they are passed correctly in Netscape.
The only proble is that my string also contains apostrophes, and, as we all know well, JavaScript is delimited with a single or double apostrophes. So, when I attempt to use the escape function with my string that contains apostrophes stored in a variable, it gets cut off.
The sticker here is that I'm getting my string from a variable that is coming from an ASP form, and it reads as follows:
Véhicule blindés, Véhicule d’infanterie, Véhicule d’artillerie, Véhicule de défense antiaérienne
Therefore, I can't elimiate my apostrophes.
I've tried replacing the apostrophes with the two digit (%27) or four digit (%uxxxx) hexadecimal equivalent, but I can't get it to work.
This is what I've got:
var selectedOption = new String(f.options[f.selectedIndex].value);
var rReg = new RegExp("\\'","g");
var results = selectedOption.replace(rReg, "%27");
document.write(results);
Can anyone help me pass a string containing special characters to an ASP page? In IE, I can send the string directly to the ASP page without any problems, but in Netscape, it translates the special characters in a wierd way and returns the wrong characters.
This is the result that I get from Netscape:
/scripts/portweb.dll?query&field=keywords&op=contains&value=Véhicule blindés
But it looks normal in IE
/scripts/portweb.dll?query&field=keywords&op=contains&value=Véhicule blindés
I'm attempting to pass a URL string from Javascript to an ASP page, and because my string contains special characters (like é, è, à, ') I'm having to use the "escape" function to encode the characters so that they are passed correctly in Netscape.
The only proble is that my string also contains apostrophes, and, as we all know well, JavaScript is delimited with a single or double apostrophes. So, when I attempt to use the escape function with my string that contains apostrophes stored in a variable, it gets cut off.
The sticker here is that I'm getting my string from a variable that is coming from an ASP form, and it reads as follows:
Véhicule blindés, Véhicule d’infanterie, Véhicule d’artillerie, Véhicule de défense antiaérienne
Therefore, I can't elimiate my apostrophes.
I've tried replacing the apostrophes with the two digit (%27) or four digit (%uxxxx) hexadecimal equivalent, but I can't get it to work.
This is what I've got:
var selectedOption = new String(f.options[f.selectedIndex].value);
var rReg = new RegExp("\\'","g");
var results = selectedOption.replace(rReg, "%27");
document.write(results);
Can anyone help me pass a string containing special characters to an ASP page? In IE, I can send the string directly to the ASP page without any problems, but in Netscape, it translates the special characters in a wierd way and returns the wrong characters.
This is the result that I get from Netscape:
/scripts/portweb.dll?query&field=keywords&op=contains&value=Véhicule blindés
But it looks normal in IE
/scripts/portweb.dll?query&field=keywords&op=contains&value=Véhicule blindés