Difference between revisions of "Retrieve a query string variable from the current page"

From Market Ruler Help
Jump to: navigation, search
(Created page with 'Retrieves the value of a Query String from the current page's query string. <code>''string'' CR_QS(''variable-name'', ''default-value'');</code> * ''variable-n…')
 
 
Line 1: Line 1:
 
Retrieves the value of a [[query string|Query String]] from the current page's query string.
 
Retrieves the value of a [[query string|Query String]] from the current page's query string.
  
<code>''string'' CR_QS(''variable-name'', ''default-value'');</code>
+
<code>''string'' __CR.query(''variable-name'', ''default-value'');</code>
  
 
* ''variable-name'' - The name of the query string variable to retrieve
 
* ''variable-name'' - The name of the query string variable to retrieve
Line 15: Line 15:
 
<code>
 
<code>
 
<script type="text/javascript"><br />
 
<script type="text/javascript"><br />
document.write(CR_QS('productId'));<br />
+
document.write(__CR.query('productId'));<br />
document.write(CR_QS('departmentId','no department'));<br />
+
document.write(__CR.query('departmentId','no department'));<br />
 
</script><br />
 
</script><br />
 
</code>
 
</code>
 
Will output the text "124123" and "no department" to the current page.
 
Will output the text "124123" and "no department" to the current page.
 +
 +
== See also ==
 +
 +
* [[__CR.query]]
  
 
[[Category:ConversionRuler]]
 
[[Category:ConversionRuler]]
 
[[Category:Technical]]
 
[[Category:Technical]]
 
[[Category:ConversionRuler JavaScript Functions]]
 
[[Category:ConversionRuler JavaScript Functions]]

Latest revision as of 18:40, 30 June 2016

Retrieves the value of a Query String from the current page's query string.

string __CR.query(variable-name, default-value);

  • variable-name - The name of the query string variable to retrieve
  • default-value - If not found, return this value instead.
  • returns the string value of the query string variable

Example: For example, if the current page URL is: http://www.example.com/?productId=124123&crsource=Google&offset=20&index=1&wrap=true Then the following code: <script type="text/javascript">
document.write(__CR.query('productId'));
document.write(__CR.query('departmentId','no department'));
</script>
Will output the text "124123" and "no department" to the current page.

See also