本文介绍了如果不存在cookie,则警报并重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户登陆页面时,我需要检查cookie是否存在,如果cookie不存在,则需要弹出警报,然后重定向到另一页面.

I need to check if a cookie exists when the user lands on a page and if the cookie does not exist I need to popup an alert and then redirect to another page.

推荐答案

if( $.cookie('cookiename') == null ) {
    alert("OH NOES U NO HAS COOKIE");
    window.location.replace('http://url');
}

这篇关于如果不存在cookie,则警报并重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 17:37