开发者

Getting part of referring url with jquery

I'm trying to set a cookie with a value that is made up of part of a referring url. The referring url looks something like:

http://webct.university.ac.uk/webct/urw/lc715920578061.tp721521425061/courseMenu.dowebct?

and I need开发者_运维技巧 to extract:

lc715920578061.tp721521425061

for reuse in another function. Would this be regex? Could anyone help with the syntax?

Many thanks Matthew


You can use replace with a regex and split like this:

var desired_part = document.referrer.replace(/^https?:\/\//gi, '').split('/')[3];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜