[英]Show login screen If the user is not logged in | jQuery
I try to display Login Screen in the spesific URL ('ads/audience-insights')
If the user is not logged in. but no luck. 如果用户未登录,则尝试在特殊的URL
('ads/audience-insights')
显示“登录屏幕('ads/audience-insights')
。
Can you correct my code? 您可以更正我的代码吗? what's wrong?
怎么了?
if (window.location.href.indexOf('ads/audience-insights') != -1) {
chrome.storage.local.get("cnt9", function(result) {
if (result.cnt9 == null || result.cnt9 == -1 || result.cnt9 >= 40) {
// show login screen
showLoginScreen();
}
});
}
This code == user Not logged in yet.. 此代码==用户尚未登录。
result.cnt9 == null || result.cnt9 == -1 || result.cnt9 >= 40
You don't have to use chrome.storage
or the callback function. 您不必使用
chrome.storage
或回调函数。
if (typeof(Storage) !== "undefined") {
var a = localStorage.cnt9;
if (a == null || a == -1 || a >= 40)
alert("Not Logged In!");
}
You also do not have to check if the user is on a specific page as the code will not execute if they are not on said page in the first place. 您也不必检查用户是否在特定页面上,因为如果用户不在该页面上,则代码将不会执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.