JavaScript的拆分網址我需要解析網址:從
http://localhost.com/kw-webapp/preview/cn/1/cmm/Default/13203/content.13203.1.1.html?context=
var url = window.location.pathname.split('/');
var _language = 4;
var _layoutuid = 5;
var _themeuid = 6;
var _contentuid = 7;
var _content = 8;
var language = url[_language];
var layoutuid = url[_layoutuid];
var themeuid = url[_themeuid];
var contentuid = url[_contentuid];
var content = url[_content];
,但我需要從這個位置解析網址:
CN/1/CMM /默認/ 13203 /內容?.13203.1.1.html上下文=
以及變量必須是:
var _language = 0; //1
var _layoutuid = 1; //cmm
var _themeuid = 2; //Default
var _contentuid = 3; //13203
var _content = 4;
我的問題是,URL可以開始這樣:
www.localhost.com/kw-webapp/kw/preview/cn/1/cmm/Default/13203/content.13203.1.1.html?context=
左右:
www.localhost.com/preview/cn/1/cmm/Default/13203/content.13203.1.1.html?context=
我怎麼能解析URL從 CN/1/CMM /默認/ 13203/content.13203.1.1.html?上下文=?
在此先感謝!
P.S.對不起,我的englisch
是網址總是形式爲'* preview/*'? (*表示任意數量的字符) – Harry