js获取url参数

阅读更多

iframe.load('showbody/servermonitor/servermonitor.html?ip=10.24.1.18&id=subsys&text=opermain&status=online&desc=子系统');

打开该页面,在该页面中获取url后面的参数方法:

 

function GetUrlParams(){

    //获取url中"?"符后的字串

    var url = location.search; 

    var theParams = new Object();

    if(url.indexOf("?") != -1){

        var str = url.substr(1);

        strs = str.split("&");

        for(var i = 0; i < strs.length; i++){

            theParams[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);

        }

    }

    return theParams;

}

 

然后

 

Ext.onReady(function () {

var urlParams = GetUrlParams();

 

Platform.app = {

serversCatalog: [

{

"title": urlParams['ip'],

"items": [

{

"id": urlParams['id'],

"text": urlParams['text'],

"ip":urlParams['ip'],

"url": "'cnaps2'",

"icon": "cnaps2.gif",

"desc": urlParams['desc'],

"status": urlParams['status']

},

 

这样就可以获取参数了。

你可能感兴趣的:(web,js,extjs,获取url后面的参数,parameters)