- Prototype Tutorial
- Prototype - Home
- Prototype - Short Overview
- Prototype - Useful Features
- Prototype - Utility Methods
- Prototype - Element Object
- Prototype - Number Processing
- Prototype - Strings Processing
- Prototype - Array Processing
- Prototype - Hash processing
- Prototype - Basic Object
- Prototype - Templating
- Prototype - Enumerating
- Prototype - Event Handling
- Prototype - Form Management
- Prototype - JSON Support
- Prototype - AJAX Support
- Prototype - Expressing Ranges
- Prototype - Periodical Execution
- Prototype Useful Resources
- Prototype - Quick Guide
- Prototype - Useful Resources
- Prototype - Discussion
Prototype - parseQuery() Method
This method parses a URI-like query string and returns an object composed of parameter/value pairs. This method is similar to the toQueryParams();
This method is realy targeted at parsing query strings (hence the default value of "&" for the separator argument).
Syntax
string.parseQuery([separator = '&']);
Return Value
Returns an object having key value pairs.
Example
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function showResult() { var str = "http://www.example.com?section=blog&id=45#comments"; var obj = str.parseQuery(); alert ( "obj.section : " + obj.section ); alert ( "obj.id : " + obj.id ); var str = "tag=ruby%20on%20rails"; var obj = str.parseQuery(); alert ( "obj.tag: " + obj.tag ); } </script> </head> <body> <p>Click the button to see the result.</p> <br /> <br /> <input type = "button" value = "Result" onclick = "showResult();"/> </body> </html>
Output
prototype_string_processing.htm
Advertisements