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];
精彩评论