开发者

Getting part of referring url with jquery

开发者 https://www.devze.com 2023-02-11 11:02 出处:网络
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:

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

精彩评论

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