I have seen lots of jQuery examples where parameter size and name are unknown. My url is only going to ever have 1 string:
http://example.com?sent=yes
I just want to detect:
- Does
sent
exist? - Is it equal to "yes"?
I have seen lots of jQuery examples where parameter size and name are unknown. My url is only going to ever have 1 string:
http://example.com?sent=yes
I just want to detect:
sent
exist?
This might be overkill, but there is a pretty popular library now available for parsing URIs, called URI.js.
Example
So simple you can use any url and get value
Usage Example
Note: If a parameter is present several times (?first=value1&second=value2), you will get the first value (value1) and second value as (value2).
If you want to find a specific parameter from a specific url:
There's this great library: https://github.com/allmarkedup/purl
which allows you to do simply
The example is assuming you're using jQuery. You could also use it just as plain javascript, the syntax would then be a little different.
Best solution here.
And this is how you can use this function assuming the URL is,
http://dummy.com/?technology=jquery&blog=jquerybyexample
.Solution from 2018
We have: http://example.com?sent=yes
Does sent exist?
Is it equal to "yes"?
and then just compare it.