You can use window.location.search
That will return everything from the ? on, and then you can parse that as needed.
jQuery: How to get hotlink from url / hash?
-
28-06-2022 - |
Domanda
I'm trying to obtain a hotlink from a url a user gets to via a link in an email
Everything after the ?
below:
http://localhost:6547/m/intro/inbox/100003120?hotlink=8095cb20284c935d9ff32c0ed61b28f1&codekitCB=400521239.247318
I need to save that hotlink into a variable to POST to a new url, however my code isn't retrieving the hash or hotlink:
jQuery:
$(document).ready(function () {
// MOBILE HACKS
var path = window.location.pathname;
var hash = window.location.hash;
console.log('dashboard.init: path = '+path);
console.log('dashboard.init: hash = '+hash);
Console:
How would you get the hash/hotlink after the ? in the url above?
Soluzione
Altri suggerimenti
Theres probably a better answer out there, but I've always just used
window.location.href.split('?')
index [1] will be everything after the ?
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow