Code sample: Parsing invoke parameters

When you set the <content> element's rim:allowInvokeParams attribute to a value of true, the start up parameters for the application are available to the start page as a query string. You can parse the query string using JavaScript.

function parseQueryString() {        

    // Create result container
    var queryParamResult;
    
    // Start at 1 to skip the leading '?'
    var query = window.location.search.substring(1);
    
    // Split the string on key-value pairs
    var params = query.split('&');
    
    // Loop through the pairs
    for ( var i = 0 ; i < params.length ; i++ ) {
        // Locate the '='
        var position = params[i].indexOf('=');
        if ( position > 0 ) {
            
            // Text before the '=' is the key
            var key = params[i].substring( 0, position );
            
            // Text after the '=' is the value
            var value = params[i].substring( position + 1 );
            
            // Add to result container
            queryParamResult[key] = value;
        }
    }
    
    return queryParamResult;
}