幾乎已經有了,但可能需要有人幫忙:
我創建了一個腳本,重定向并設定來自我們網站任何頁面的cookie。
我創建了一個腳本來重定向并設定一個來自我們網站任何頁面的cookie。因此,即使用戶從直接鏈接到一篇新聞文章,它也會將他們重定向到我們的 "閃光 "頁面,并設定一個 "cookie "以避免進一步重定向。我的這部分作業很完美。
$(document).ready(function(/span>) {
if (typeof Cookies. get('secondvisit') === 'undefined') {
window.location.href = "/index-donate.php";
}
})
然而,我們現在要捕獲他們首先來到的URL,并創建一個變數,這樣我們就可以讓他們在閱讀我們的SPLASH頁面后被鏈接回該頁面。
所以在上面的例子中:
通過直接鏈接進入。/news/article1.php 沒有檢測到cookie,所以我們首先需要 "捕獲 "他們通過"$page-refer "進入的頁面,然后將他們重定向到我們的Splash頁面。在閃亮的頁面上,我們將向他們展示一個帶有"$page-refer "鏈接的 "Proceed to webpage "的LINK。
我嘗試了這個方法(如下),但這只是抓取了 "谷歌 "頁面,而不是他們首先點擊的我們的網頁。
謝謝!
$(document).ready(function(>/span>) {
if (typeof Cookies. get('secondvisit') === 'undefined') {
var referringURL = document.referrer。
var local = referringURL.substring(referringURL.com). indexOf("?"), referringURL.length)。)
location.href = "/index-donate.php" local;
}
})
uj5u.com熱心網友回復:
我想你可以在做重定向的時候把URL作為一個cookie添加進去,例如:
$(document).ready(function (>/span>) {
if (typeof Cookies. get('secondvisit') === 'undefined') {
Cookies.set('initialvisitedpage', window. location.href)。)
window.location.href = "/index-donate.php"/span>。
}
});
然后你可以將他們重定向到cookie的值:
$(document).ready(function(>/span>) {
if (typeof Cookies. get('secondvisit') === 'undefined') {
window.location.href = Cookies. get('initialvisitedpage') || '/'; // or whatever this could default to in case they don't have the cookie。
}
})
uj5u.com熱心網友回復:
拼湊出一個答案,效果很好,感謝大家的評論和推送:
在頁腳腳本模板上:$(document).ready(function () {
if (typeof Cookies. get('secondvisit') === 'undefined') {
location.href = "/index-donate.php?page-refer=" encodeURIComponent( location.href)。
}
})
然后在我的Splash頁面上:
我通過$_GET['page-refer']捕獲了變數$pageredirect,然后將其作為一個鏈接進一步呈現在頁面中(如果設定了)!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/306716.html
標籤:
