开发者

Pull variable from Query String and add into JS redirect URL

开发者 https://www.devze.com 2023-02-25 15:02 出处:网络
I\'m trying to get the value of a variable in the query string example.com/?hop=test And then pass it to a JavaScript in this form:

I'm trying to get the value of a variable in the query string example.com/?hop=test

And then pass it to a JavaScript in this form:

var exitsplashpage = 'http://example2.com/?hop=original_hop';

How do I get the original hop varia开发者_Python百科ble value using JavaScript and what is the correct format to put it into the exitsplashpage var?

Thanks!


Using this getQueryString() function from the link that @Felix Kling posted, you would do the following:

var exitsplashpage = 'http://example2.com/?hop=' + getQueryString()["hop"];

Either that, or have a look at jQuery Query String Object, with which you'd do this:

var exitsplashpage = 'http://example2.com/?hop=' + $.query.get("hop");


Try this:

var exitsplashpage = window.location.search.match(/\?hop=([^\&]*)/)[1]
0

精彩评论

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