从查询字符串中提取变量并添加到 JS 重定向 URL [英] Pull variable from Query String and add into JS redirect URL
本文介绍了从查询字符串中提取变量并添加到 JS 重定向 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试获取查询字符串中变量的值 example.com/?hop=test
I'm trying to get the value of a variable in the query string example.com/?hop=test
然后以这种形式将其传递给 JavaScript:
And then pass it to a JavaScript in this form:
var exitsplashpage = 'http://example2.com/?hop=original_hop';
如何使用 JavaScript 获取原始跃点变量值以及将其放入 exitsplashpage 变量的正确格式是什么?
How do I get the original hop variable value using JavaScript and what is the correct format to put it into the exitsplashpage var?
谢谢!
推荐答案
试试这个:
var exitsplashpage = window.location.search.match(/\?hop=([^\&]*)/)[1]
这篇关于从查询字符串中提取变量并添加到 JS 重定向 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文