2012-03-15 9 views
0

私のウェブサイトは現在ホームページでjavascriptポップアップを実行しています。ユーザーがホームページをクリックすると、ユーザーはホームページにジャンプし、javascript popが表示されますが、ユーザーが再度このホームページをクリックすると、このスクリプトは実行されません。このスクリプトは1日のみ有効です。javascriptでクッキーを設定 - ポップアップと統合

だから、どのように私のjavascriptのポップアップでクッキーを統合するには?このような

<script> 

    var $xx = jQuery.noConflict(); 

    $xx(document).ready(function() { 

    //select all the a tag with name equal to modal 
    $xx('a[name=modal]').click(function(e) { 
     //Cancel the link behavior 
     e.preventDefault(); 

     //Get the A tag 
     var id = $xx(this).attr('href'); 

     //Get the screen height and width 
     var maskHeight = $xx(document).height(); 
     var maskWidth = $xx(window).width(); 

     //Set heigth and width to mask to fill up the whole screen 
     $xx('#mask').css({'width':maskWidth,'height':maskHeight}); 

     //transition effect  
     $xx('#mask').fadeIn(1000); 
     $xx('#mask').fadeTo("slow",0.90); 

     //Get the window height and width 
     var winH = $xx(window).height(); 
     var winW = $xx(window).width(); 

     //Set the popup window to center 
     $xx(id).css('top', winH/2-$xx(id).height()/1); 
     $xx(id).css('left', winW/2-$xx(id).width()/2); 

     //transition effect 
     $xx(id).fadeIn(1000); 

    }); 

    //if close button is clicked 
    $xx('.window .close').click(function (e) { 
     //Cancel the link behavior 
     e.preventDefault(); 

     $xx('#mask').hide(); 
     $xx('.window').hide(); 
    });    

}); 
</script> 
<script type="text/javascript"> 
window.onload = function() { $xx('a[href="#dialog1"]:eq(0)').click(); 
} 
</script> 
+0

非常にわからないいくつかのdocument.cookieグーグル:「一日のためにのみアクティブにこのスクリプトを」、あなたは別の日が来る間、1日以内に、各ユーザーは、一度ポップアップウィンドウが表示されていることを意味しました、もう一度それを見ますか? –

+0

あなたが話していたクッキーはどこにありますか?あなたの問題をより明確に説明してください、タイトルは少し誤解を招くものです。ワンクリック後にポップアップを無効にしますか? – specialscope

+0

はい.. 24時間だけ – ruslyrossi

答えて

0

何かを:完璧

* このポップアップ走行だけ左クッキースクリプト

URL http://tsubamecorp.com/home/index.php?route=extras/blog/getblogcategory&blogpath=41

が、これは私のJavascriptをポップアップしています。クッキーの有効期限は、そのクッキーがsysによって削除された後であることを意味します。あなたの質問について

Cookie = { 
    get:function (key) { 
     var ret = this.toObj()[key]; 
     if(ret === undefined){ 
      return ret; 
     } 
     return unescape (this.toObj()[key]); 
    }, 
    set:function (key, value, expires) { 
     if (expires){ 
      var exdata = new Date(); 
      exdata = exdata.setDate (exdata.setDate() + expires).toGMTString(); 
     } 
     document.cookie = key+"="+escape(value) + (exdata ? "; expires= " + exdata : ""); 
    }, 
    remove:function (key) { 
     document.cookie = key+"=remove;expires="+(new Date).toGMTString(); 
    }, 
    toJSON:function () { 
     return JSON.stringify(this.toObj); 
    }, 
    toObj:function () { 
     var ret={}, cookiearr = document.cookie.split(";"); 
     var i, start, key, value; 
     for (i = 0; l = cookiearr[ i++ ];) { 
      start = l.indexOf ("="); 
      ret [ l.slice(0, start) ] = l.slice (start+1); 
     } 
     return ret; 
    } 
} 
+0

ok..thanks ..試してみます – ruslyrossi

関連する問題