0

I use the following to read variables from a URL:

$.urlParam = function(name){
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
    return results[1] || 0;
}

The URLs in question are set like this:

<a href="View?wl_id=' + i.event_id + '&title=' + encodeURIComponent(i.event_title) + '">

I have an example URL which is:

...&title=New%20clothes!

To see it I alert(decodeURIComponent($.urlParam('title'))); which shows New Clothes! - perfect

I have another example which is:

...&title=Favorite%20Fragrances

This when alerted shows F - that's it

Another example:

...&title=private%20testing

When alerted produces 0

Any ideas why they don't all produce what they should?

1 Answer 1

1

&amp; is not correct. Use & instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.