Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get URL parameters with Dojo toolkit

I need know how can get a parameter from the URL. I mean if have

   page1.html?id=12345 

I need to get the id from the URL, I know that in jQuery is $.url.param("id");

But in Dojo how it is done?

like image 762
Alexander Avatar asked Jul 26 '11 16:07

Alexander


People also ask

How do I find the URL parameter?

Method 1: Using the URLSearchParams Object The URLSearchParams is an interface used to provide methods that can be used to work with an URL. The URL string is first separated to get only the parameters portion of the URL. The split() method is used on the given URL with the “?” separator.

Which three components does the Dojo toolkit provide?

Components of the Dojo toolkit are: Core — This component contains the central and non-visual modules. Dijit — This is a widget and layout library for the user interface. Dojox — This component consists of experimental modules that are not yet stable enough to be included in Dojo and Dijit.

What is a URL parameter?

URL parameter is a way to pass information about a click through its URL. You can insert URL parameters into your URLs so that your URLs track information about a click. URL parameters are made of a key and a value separated by an equals sign (=) and joined by an ampersand (&).

What is URL parameters in API?

API Query parameters can be defined as the optional key-value pairs that appear after the question mark in the URL. Basically, they are extensions of the URL that are utilized to help determine specific content or action based on the data being delivered.


1 Answers

The relevant function is dojo.queryToObject(string) it returns an object containing the key-value pairs from the query string. This way, you can use either

dojo.queryToObject("id=12345").id

or

dojo.queryToObject("id=12345")['id']

Do note that this function receives only the query part of the url. You can get this information via document.location.search, as mentioned by Ghislain in the comments.

like image 196
hugomg Avatar answered Oct 03 '22 19:10

hugomg