Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am able to get the querystring from url like this using regex and javascript: But I need to get rid of these %22...these don't show up in IE, just in FF..How do I do that? Ineeed everything after k=..but without %22..

 <script type="text/javascript">document.write('<div class="DynamicSearchTitle">
Showing All Results For ' +  
location.href.match(/\&k\=(.+)/)[1]+ ' Matches </div>'); 
</script>

URL

http://mysite/sites/dev/contact-us/Pages/LocationSearchTestPage.aspx?s=bcs_locations&k=%22Hospital%22%20OR%20%22Office%22

share|improve this question
URL doesn't work. "Page Not Found". – Alex Feb 26 '12 at 21:14
why would you need the URL to work? I just included sample URL..the real url is not live yet.. – Anjana Sharma Feb 26 '12 at 21:18
Stop using spaces and strange characters in your querystring and you should be golden? – adeneo Feb 26 '12 at 21:19
I wish I could do that! Strange world of Sharepoint has weird ways to get things done :) – Anjana Sharma Feb 26 '12 at 21:22
Note that you can extract the query string more conveniently using location.search. – Neil Feb 26 '12 at 21:56

2 Answers

up vote 1 down vote accepted

The URL is broken so I can't take a look at the whole code, but I think what you're looking for is the decodeURI-function.

decodeURI("%22")

for example would return "

Unescapeing the url from your question:

decodeURI("&k=%22Hospital%22%20OR%20%22Office%22");

returns &k="Hospital" OR "Office"

share|improve this answer
1  
unescape is bad. It does not work for non-ASCII characters. -1 for w3schools reference. – shiplu.mokadd.im Feb 26 '12 at 21:22
edited and thanks for the info, wasn't aware of that! – Alex Feb 26 '12 at 21:28
Thank you sir! Worked great! – Anjana Sharma Feb 26 '12 at 21:32

You can get all the Query String component by simple JS function described here

Use it like this,

var uparts = getUrlParts(location.href);
var the_K = uparts["k"];
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.