Users will be hitting up against a URL that contains a query string called inquirytype
. For a number of reasons, I need to read in this query string with javascript (Dojo) and save its value to a variable. I've done a fair amount of research trying to find how to do this, and I've discovered a few possibilities, but none of them seem to actually read in a query string that isn't hard-coded somewhere in the script.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Since dojo 0.9, there is a better option, queryToObject.
See this similar question with what I think is a cleaner answer.
You can access parameters from the url using location.search without Dojo Can a javascript attribute value be determined by a manual url parameter?
Then you could do the following to extract id from the url
/hello.php?id=5&name=value
Dojo provides http://dojotoolkit.org/reference-guide/dojo/queryToObject.html which is a bit smarter than my simple implementation and creates arrays out of duplicated keys.
In new dojo it's accessed with io-query: