PDA

View Full Version : How to ger Url parameters with Sencha Touch



alexanderHs
19 Aug 2011, 6:09 PM
How can get a parameter from the url, i mean if have
page1.html#token=12345
i need to get the token from the url, in sencha how it is?

steve1964
20 Aug 2011, 8:56 AM
Hi, this is not related with Sencha Touch, i use this javascript function to retrieve url parameter:


function gup( name ){
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}


var urlparam = gup('yourParam');

interfasys
20 Aug 2011, 2:46 PM
Ext.urlDecode("foo=1&bar=2"); // returns {foo: "1", bar: "2"}