我会保持简短的。
我有一个WordPress页面,需要在4秒后将用户重定向到另一个URL。此URL是一个查询参数。
这里有一个例子。
它们在我的页面上登陆的网址是:
https://koniecstresu.sk/dakujem5/?wj_lead_unique_link_live_room=https%3a%2f%2fevent.webinarjam.com%2fgo%2flive%2f15%2fmqx6vt5coriq3rforg
wj_lead_unique_link_live_room是参数。
在本例中,需要在4秒后将它们重定向到此URL:https://event.webinarjam.com/go/live/15/mqx6vt5coriq3rforg
我需要在HTML和JavaScript中这样做,我可以在Elementor中嵌入到WordPress页面中...尝试了许多不同的方法,但我无法弄清楚如何首先获得URL参数。
谢谢大家!
您可以检查是否使用URLSearchParams设置了该参数,如果该参数存在,则添加一个在4秒后重定向到给定目标的超时。
const params = new URLSearchParams(window.location.href)
if( params.has('wj_lead_unique_link_live_room') {
const redirectUrl = decodeURIComponent(params.get('wj_lead_unique_link_live_room'))
setTimeout(() => window.location.href = redirectUrl, 4000)
}