2012-03-25 16 views
-1

スクリプトにCookieの添付ファイルを追加するにはどうすればよいですか?私はこのウェブサイトを見て、コードを置こうとしましたが、今まで働いたことはありませんでした。モーダルウィンドウは一度しか表示されません。

これは私のコードです:ウィンドウは一度のみ/ユーザーは素晴らしいことだが開きますので、私はクッキーのセグメントを追加することができます

$(document).ready(function() { 

//select all the a tag with name equal to modal 
$('a[name=modal]').click(function(e) { 
    //Cancel the link behavior 
    e.preventDefault(); 
    //Get the A tag 
    var id = $(this).attr('href'); 

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

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

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

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

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

    //transition effect 
    $(id).fadeIn(2000); 

}); 

//if close button is clicked 
$('.window .close').click(function (e) { 
    //Cancel the link behavior 
    e.preventDefault(); 
    $('#mask, .window').hide(); 
});  

//if mask is clicked 
$('#mask').click(function() { 

誰でも。

+1

http://tinyurl.com/cfsuy6 – Ben

答えて

0

あなたはone()で一度だけclickにイベントを添付することができます:

$('a[name=modal]').one('click', function(){ ... }); 
+0

が、私はそれはOPがクッキーを使用しての言及与えられ、何を望んだとは思いません。ページがリフレッシュされると、モーダルウィンドウが再度開くことができます。 –

+0

それは正しいですが、質問はちょっと混乱しますが、これは助けになるかもしれませんが、分かりません。 – elclanrs

関連する問題