Changes

Reading QueryString parameters using JavaScript

843 bytes added, 16:21, 26 July 2015
if
It is possible to read QueryString parameters from any page in bxp.


In the fn_javascript_general.js library included on every page is a function called fn_Gen_getParameterByName(name)


Using this function call on any page in bxp allows you to check for the existence of a querystring parameter.


Using this page as an example we could write


<syntaxhighlight lang="javascript">
//Firstly we pull the parameter into a variable
var strTitle = fn_Gen_getParameterByName("title");

//Now we check if the parameter was found
if (strTitle){
//Now only do something if the variable has some contents
if (strTitle != ''){
//If the variable contains what you are looking for
if (strTitle == 'Reading_QueryString_parameters_using_JavaScript'){
//Perform whatever action you need.
alert('Your page detected');
}
}
}
</syntaxhighlight>
7,528
edits