1

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

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

2 Answers 2

1

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"

answered Feb 26, 2012 at 21:17
Sign up to request clarification or add additional context in comments.

1 Comment

unescape is bad. It does not work for non-ASCII characters. -1 for w3schools reference.
1

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"];
answered Feb 26, 2012 at 21:16

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.