JS在第一次访问时重定向到启动页面
JS to redirect to a splash page on first visit?
我正在尝试修改一些代码,以在用户第一次访问时将用户定向到"创建帐户"挤压页面。我想我很接近,但我需要一点帮助。关于我哪里出错了有什么建议吗?
<script type="text/javascript">
$(document).ready(function() {
// check cookie
var visited = $.cookie("visited")
if (visited == null) {
window.location = "content/content-article.asp?ArticleID=4998"
$.cookie('visited', 'yes');
alert($.cookie("visited"));
}
// set cookie
$.cookie('visited', 'yes', { expires: 10,000, path: '/' });
});
好的 - 我一直在挖掘并找到一个不同的脚本。这是以防其他人试图做同样的事情:
<script type="text/javascript">
function redirect(){
var thecookie = readCookie('doRedirect');
if(!thecookie){window.location = 'http://yournetwork.com/splash';
}}function createCookie(name,value,days){if (days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";}function readCookie(name){var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++){var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;}window.onload = function(){redirect();createCookie('doRedirect','true','999');}
试试这个:
$(document).ready(function() {
// check cookie
var visited = $.cookie("visited")
// set cookie
$.cookie('visited', 'yes', { expires: 10,000, path: '/' });
if (visited == null) {
$.cookie('visited', 'yes');
alert($.cookie("visited"));
window.location = "content/content-article.asp?ArticleID=4998"
}
});
执行代码后将位置更改为另一个站点
相关文章:
- 通过javascript重定向html传递php变量
- JavaScript下拉菜单-点击按钮并根据所选值重定向到url
- 使用angular重定向到html页面
- 如何在chrome扩展中重定向到html页面
- 无法从jquery Mobile导航栏重定向到另一个页面
- ng视图外的链接重定向到ng视图内的页面
- 在phonegap应用程序内部重定向不起作用
- CORS-重定向到第二个GET正在接收的页面
- 使用重定向来启动应用程序,并且仍然停留在asp.net中的同一页面中
- JavaScript窗口重定向不会启动
- JS在第一次访问时重定向到启动页面
- CasperJS的启动在应该有重定向时不起作用
- 如何通过单击取消javascript函数启动的定时重定向
- 快速重新启动匹配路由-重定向
- 使用二维码启动应用程序或重定向到网页
- 启动屏幕后,iPhone ChildBrowser重定向
- 从webview启动应用程序,如果未安装,则重定向到播放商店
- javascript:启动新窗口,重定向现有窗口,在新窗口中设置焦点-如何
- 移动电子邮件启动+点击事件重定向
- 是否可以重定向用户以启动扫描仪应用程序