Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用WebStorage显示“无”_Javascript_Css_Wordpress - Fatal编程技术网

Javascript 如何使用WebStorage显示“无”

Javascript 如何使用WebStorage显示“无”,javascript,css,wordpress,Javascript,Css,Wordpress,嗨,我想做的是,如果referer是example.com,则隐藏我正在使用web存储但不工作的所有页面的一些数据 <script> if (document.referrer !== 'example.com/') { // Store localStorage.setItem('displaynone', ' <style> .top-bar{display:none!important;} .woocommerce-breadcrumb{display:no

嗨,我想做的是,如果referer是example.com,则隐藏我正在使用web存储但不工作的所有页面的一些数据

<script>


if (document.referrer !== 'example.com/') {
// Store
localStorage.setItem('displaynone', ' <style> 

.top-bar{display:none!important;}
.woocommerce-breadcrumb{display:none!important;}
.register-benefits{display:none!important;}
.before-login-text{display:none!important;}
#colophon{display:none!important;} </</style>');
}

localStorage.getItem('displaynone');




</script>

如果(document.referer!=“example.com/”){
//贮藏
setItem('displaynone','
.top栏{显示:无!重要;}
.woocommerce面包屑{显示:无!重要;}
.注册福利{显示:无!重要;}
.登录前文本{显示:无!重要;}

#colophon{display:none!important;}hello此代码将帮助您使用webstorage.js

    var cookieStoragePlan = {
        create: function(name, value, path, domain, expires){
    if(!name)
        return null;
    var cookie = (name) + '=';

    var time = new Date();
    time.setTime((new Date().getTime())+1000*60*60*24);

    if(typeof expires !== 'undefined'){
        time.setTime((new Date().getTime())+expires*1000);
    }

    cookie += typeof value === 'undefined' ? '' : encodeURIComponent(value);
    cookie += typeof path === 'undefined' ? '' : '; path=' + (path);
    //cookie += typeof domain === 'undefined' ? '; domain=' +       

    encodeURIComponent(document.domain)  : '; domain=' + encodeURIComponent(domain);
    cookie += '; expires=' + time.toUTCString();

    document.cookie = cookie;
    //console.log(document.cookie);
},

getValue: function(name){
    if(!name){
        return null;
    }
    var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
    var cookie = decodeURIComponent(document.cookie);
    var result = cookie.match(reg);
    return (!result ? null : result[2]);
},

isPresent: function(name){
    if(!name){
        return false;
    }
    var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
    return reg.test(decodeURIComponent(document.cookie));
},

remove: function(name){
    if(!name || this.isPresent(name)===false){
        return null;    
    }
    var time = new Date();
    time.setTime(0);
    var cookie = name + '=; expires=' + time.toUTCString(); 
    document.cookie = cookie;
},

clear: function(){
    var allCookie = decodeURIComponent(document.cookie);
    var row = allCookie.split('; ');
    for(var i = 0; i < row.length; ++i){
        var pos = row[i].indexOf('=');
        var key = row[i].substring(0, pos);
        this.remove(key);
    }
}
    };

    var userDataPlan = {
storage: null,

init: function(expires){
    if(this.storage !== null){
        if(expires!=='undefined'){
            var now = new Date().getTime();
            var time = now + 1000*60*60*24*expires;
            this.storage.expires = new Date(time).toUTCString();
        }   
        return true;
    }
    try{        
        this.storage = document.createElement('div');
        //this.storage.id = 'userDataPlan';
        this.storage.style.display = 'none';
        this.storage.addBehavior('#default#userData');
        document.body.appendChild(this.storage);
        if(expires!=='undefined'){
            var now = new Date().getTime();
            var time = now + 1000*60*60*24*expires;
            this.storage.expires = new Date(time).toUTCString();
        }
    }
    catch(e){
        return false;
    }
    return true;
        },

        create: function(name, value, expires){

    if(!this.init(expires) || !name)
        return false;
    try{    
        this.storage.load('myUserDataPlan');
        this.storage.setAttribute(name, value || null);

        this.storage.save('myUserDataPlan');
    }
    catch(e){
        return false;
    }
    return true;
},

getValue: function(name){
    if(!this.init() || !name){
        return null;
    }
    this.storage.load('myUserDataPlan');
    return this.storage.getAttribute(name) || null;
},

isPresent: function(name){

    if(!this.init() || !this.getValue(name))
        return false;
    return true;
},

remove: function(name){
    if(!this.isPresent(name))
        return true;
    this.storage.removeAttribute(name);
    try{
        storage.save('myUserDataPlan');
    }
    catch(e){
        return false;
    }
    return false;
},

clear: function(){
    if(!this.init(-1)){
        return false;
    }
    storage.parentNode.removeChild(storage);
    return true;
}
    };

    var localStoragePlan = {
create: function(name, value){
    localStorage.setItem(name, value);
},

getValue: function(name){
    return localStorage.getItem(name);
},

isPresent: function(name){
    if(this.getValue(name))
        return true;
    return false;
},

remove: function(name){
    localStorage.removeItem(name);
},

clear: function(){
    localStorage.clear();
}
    };

    var StoragePlan = function(){};

    StoragePlan.prototype = {
handler: function(){
    return cookieStoragePlan;
    if(typeof window.localStorage === 'object'){
        //alert("localStoragePlan");
        return localStoragePlan;
    }
    else if(document.body.addBehavior()){
        //alert("userDataPlan");
        return userDataPlan;
    }
    else {
        //alert("cookieStoragePlan");
        return cookieStoragePlan;
    }
  }
      };
var cookieStoragePlan={
创建:函数(名称、值、路径、域、过期){
如果(!name)
返回null;
变量cookie=(名称)+'=';
变量时间=新日期();
time.setTime((new Date().getTime())+1000*60*60*24);
if(typeof expires!=“未定义”){
time.setTime((new Date().getTime())+expires*1000);
}
cookie+=typeof值==='undefined'?'':encodeURIComponent(值);
cookie+=typeof路径==='未定义'?'':';路径='+(路径);
//cookie+=typeof域==='undefined'?';域='+
encodeURIComponent(document.domain):';domain='+encodeURIComponent(domain);
cookie+=';expires='+time.toutString();
document.cookie=cookie;
//console.log(document.cookie);
},
getValue:函数(名称){
如果(!name){
返回null;
}
var reg=new RegExp(“(^ |)”+name+“=([^;]*)(;|$)”;
var cookie=decodeURIComponent(document.cookie);
var结果=cookie.match(reg);
返回(!result?null:结果[2]);
},
isPresent:函数(名称){
如果(!name){
返回false;
}
var reg=new RegExp(“(^ |)”+name+“=([^;]*)(;|$)”;
返回注册测试(decodeURIComponent(document.cookie));
},
删除:函数(名称){
如果(!name | | this.isPresent(name)==false){
返回null;
}
变量时间=新日期();
时间。设置时间(0);
var cookie=name+'=;expires='+time.toutString();
document.cookie=cookie;
},
清除:函数(){
var allCookie=decodeURIComponent(document.cookie);
var row=allCookie.split(“;”);
对于(变量i=0;i
您好,此代码将帮助您使用webstorage.js

    var cookieStoragePlan = {
        create: function(name, value, path, domain, expires){
    if(!name)
        return null;
    var cookie = (name) + '=';

    var time = new Date();
    time.setTime((new Date().getTime())+1000*60*60*24);

    if(typeof expires !== 'undefined'){
        time.setTime((new Date().getTime())+expires*1000);
    }

    cookie += typeof value === 'undefined' ? '' : encodeURIComponent(value);
    cookie += typeof path === 'undefined' ? '' : '; path=' + (path);
    //cookie += typeof domain === 'undefined' ? '; domain=' +       

    encodeURIComponent(document.domain)  : '; domain=' + encodeURIComponent(domain);
    cookie += '; expires=' + time.toUTCString();

    document.cookie = cookie;
    //console.log(document.cookie);
},

getValue: function(name){
    if(!name){
        return null;
    }
    var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
    var cookie = decodeURIComponent(document.cookie);
    var result = cookie.match(reg);
    return (!result ? null : result[2]);
},

isPresent: function(name){
    if(!name){
        return false;
    }
    var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
    return reg.test(decodeURIComponent(document.cookie));
},

remove: function(name){
    if(!name || this.isPresent(name)===false){
        return null;    
    }
    var time = new Date();
    time.setTime(0);
    var cookie = name + '=; expires=' + time.toUTCString(); 
    document.cookie = cookie;
},

clear: function(){
    var allCookie = decodeURIComponent(document.cookie);
    var row = allCookie.split('; ');
    for(var i = 0; i < row.length; ++i){
        var pos = row[i].indexOf('=');
        var key = row[i].substring(0, pos);
        this.remove(key);
    }
}
    };

    var userDataPlan = {
storage: null,

init: function(expires){
    if(this.storage !== null){
        if(expires!=='undefined'){
            var now = new Date().getTime();
            var time = now + 1000*60*60*24*expires;
            this.storage.expires = new Date(time).toUTCString();
        }   
        return true;
    }
    try{        
        this.storage = document.createElement('div');
        //this.storage.id = 'userDataPlan';
        this.storage.style.display = 'none';
        this.storage.addBehavior('#default#userData');
        document.body.appendChild(this.storage);
        if(expires!=='undefined'){
            var now = new Date().getTime();
            var time = now + 1000*60*60*24*expires;
            this.storage.expires = new Date(time).toUTCString();
        }
    }
    catch(e){
        return false;
    }
    return true;
        },

        create: function(name, value, expires){

    if(!this.init(expires) || !name)
        return false;
    try{    
        this.storage.load('myUserDataPlan');
        this.storage.setAttribute(name, value || null);

        this.storage.save('myUserDataPlan');
    }
    catch(e){
        return false;
    }
    return true;
},

getValue: function(name){
    if(!this.init() || !name){
        return null;
    }
    this.storage.load('myUserDataPlan');
    return this.storage.getAttribute(name) || null;
},

isPresent: function(name){

    if(!this.init() || !this.getValue(name))
        return false;
    return true;
},

remove: function(name){
    if(!this.isPresent(name))
        return true;
    this.storage.removeAttribute(name);
    try{
        storage.save('myUserDataPlan');
    }
    catch(e){
        return false;
    }
    return false;
},

clear: function(){
    if(!this.init(-1)){
        return false;
    }
    storage.parentNode.removeChild(storage);
    return true;
}
    };

    var localStoragePlan = {
create: function(name, value){
    localStorage.setItem(name, value);
},

getValue: function(name){
    return localStorage.getItem(name);
},

isPresent: function(name){
    if(this.getValue(name))
        return true;
    return false;
},

remove: function(name){
    localStorage.removeItem(name);
},

clear: function(){
    localStorage.clear();
}
    };

    var StoragePlan = function(){};

    StoragePlan.prototype = {
handler: function(){
    return cookieStoragePlan;
    if(typeof window.localStorage === 'object'){
        //alert("localStoragePlan");
        return localStoragePlan;
    }
    else if(document.body.addBehavior()){
        //alert("userDataPlan");
        return userDataPlan;
    }
    else {
        //alert("cookieStoragePlan");
        return cookieStoragePlan;
    }
  }
      };
var cookieStoragePlan={
创建:函数(名称、值、路径、域、过期){
如果(!name)
返回null;
变量cookie=(名称)+'=';
变量时间=新日期();
time.setTime((new Date().getTime())+1000*60*60*24);
if(typeof expires!=“未定义”){
time.setTime((new Date().getTime())+expires*1000);
}
cookie+=typeof值==='undefined'?'':encodeURIComponent(值);
cookie+=typeof路径==='未定义'?'':';路径='+(路径);
//cookie+=typeof域==='undefined'?';域='+
encodeURIComponent(document.domain):';domain='+encodeURIComponent(domain);
cookie+=';expires='+time.toutString();
document.cookie=cookie;
//console.log(document.cookie);
},
getValue:函数(名称){
如果(!name){
返回null;
}
var reg=new RegExp(“(^ |)”+name+“=([^;]*)(;|$)”;
var cookie=decodeURIComponent(d