javascript - Url parameters extraction -
var results = new regexp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); could u please explain exactlly happening in above line of code.
thanks in advance.
- you create variable name of
resultsscoped execution context. - you invoke
regexpconstructor thereby instantiating object , pass string used regex. have way because can't concatenate regex literals outside data. - the regex says match of
\,?or&followednamevariable, , literal=, make capturing group of every character besides&or#, 0 or more times. - you call
exec()method on newregexpobject,window.location.href(the current url) argument. - the return of assigned
resultsvariable. - the capturing group's contents (if successful) in
results[1].
or
you getting param name :)
Comments
Post a Comment