从Everwebinar URL重定向日期和时间页面



我希望能够将自定义Everwebinar确认页面(在我的域上(访问者重定向到确认页面URL中包含的指定日期和时间的特定URL。

确认页面URL如下所示:

https://website.com/pagename?preview_theme_id=2151207349?wj_lead_email=email%40outlook.com&wj_lead_first_name=FirstName&wj_lead_last_name=LastName&wj_lead_phone_country_code=&wj_lead_phone_number=&wj_lead_unique_link_live_room=https%3A%2F%2Fevent.webinarjam.com%2Fgo%2Flive%2F1%2Fk6znqu2twiyznhp42&wj_event_ts=1658918700&wj_event_tz=Europe%2FLondon&wj_next_event_date=Wednesday%2C+24+August+2022&wj_next_event_time=2%3A00+PM&wj_next_event_timezone=London+GMT+%2B1

简单的javascript重定向是合适的,只要重定向日期、时间和URL都是从上面的确认页面URL中提取的,因为每个访问者都有一个唯一的URL。

提前感谢您的帮助。

首先,需要注意的是,您作为示例给出的确认页面URL包含两个问号,这是无效的。这可能是一个拼写错误,但URL搜索参数之前应该只有一个问号,所有搜索参数都用一个与号分隔(&(。

也就是说,有几种方法可以获得URL搜索参数的值,然后根据URL中提供的日期/时间进行重定向。这里使用的主要内容是URLSearchParams(),它允许您获得一个包含所有可用搜索参数的对象。从那里开始,wj_event_ts是一个可用于比较日期/时间的时间戳。

对于这个例子,我将使用您提供的URL,但如果这个JavaScript在确认页面上运行,我已经评论了如何获取当前URL。

// If run on the actual confirmation page, use:
// let currentURL = window.location.href;
let currentURL = new URL("https://website.com/pagename?preview_theme_id=2151207349&wj_lead_email=email%40outlook.com&wj_lead_first_name=FirstName&wj_lead_last_name=LastName&wj_lead_phone_country_code=&wj_lead_phone_number=&wj_lead_unique_link_live_room=https%3A%2F%2Fevent.webinarjam.com%2Fgo%2Flive%2F1%2Fk6znqu2twiyznhp42&wj_event_ts=1658918700&wj_event_tz=Europe%2FLondon&wj_next_event_date=Wednesday%2C+24+August+2022&wj_next_event_time=2%3A00+PM&wj_next_event_timezone=London+GMT+%2B1"),
searchParams = new URLSearchParams(currentURL.search),
nextEventDate = new Date(`${searchParams.get("wj_next_event_date")} ${searchParams.get("wj_next_event_time")} ${searchParams.get("wj_next_event_timezone").substr(searchParams.get("wj_next_event_timezone").indexOf("GMT"))}`);
if(Date.now() >= searchParams.get("wj_event_ts")*1000) {
// It is currently past the date in the URL
console.log("Redirecting... Current Event");
//window.location.href = searchParams.get("wj_lead_unique_link_live_room");
}
// If you want to use the next_event_date value instead, use this section
if(Date.now() >= nextEventDate.getTime()) {
console.log("Redirecting... Next Event");
//window.location.href = searchParams.get("wj_lead_unique_link_live_room");
}

编辑URL中似乎有多个日期,但没有指定要使用的日期/时间。我添加了另一个注释掉的部分,以使用next_event_date值,而不是event_date时间戳。

我使用了另一种获取URL参数的方法,并且成功了。

const queryString = window.location.search;
console.log(queryString);
const urlParams = new URLSearchParams(queryString);
if (urlParams.has('wj_event_ts')) {
if(Date.now() >= urlParams.get('wj_event_ts')*1000) {
// It is currently past the date in the URL
console.log('Redirecting... Current Event');
window.location.href = urlParams.get('wj_lead_unique_link_live_room');
}
}

最新更新