我目前正在执行一项任务,例如,用户访问 www.site.com 满足特定条件,我应该在页面中进行一些视觉转换。但这应该只在用户第一次看到该页面时发生。随后,如果用户忽略号召性用语并浏览网站,则一切正常。
为了确保对于给定的 session ,这种转换仅在我使用 document.referrer 检查它是否为 1. 一个“”字符串,表示用户可能直接输入了 www.site.com 地址
- !document.referrer.match(/www.site.com/gi); - 确保用户不会从内部页面再次返回主页。
这在大多数情况下都有效,除非当用户进入检查漏斗时,网址更改为安全的 https://,并且当他返回 site.com 主页时, document.referrer 返回一个空字符串,这让我感到困惑逻辑 a 用户在 URL 中输入地址
有没有其他可靠的方法来解决这个问题。非常感谢任何帮助,并感谢您花时间阅读我的问题
最佳答案
function transformation(){
// transformation code
}
if(document.cookie.match(/someCookieName/) && document.location.href.match(/transformationPageURL/)){
// call the transformation
transformation();
// set session cookie
document.cookie="someCookieName=true;";
}else{
// not the url to perform transformation or the cookie is already set which means its the same session.
//但如果用户再次输入相同的主页 url,由于设置了 cookie,转换//不会出现。但普通用户//访问网站并再次进入首页url的变化可能会较小 }
关于javascript - 寻找网站推荐人的可靠方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33640559/