2012-08-03 39 views
0

我使用sohtanaka.com中的'簡單內聯模式窗口css'腳本。由於這個網站離線,我現在找不到我的答案。更改簡單的內聯模式窗口css腳本

有人可以幫我嗎?

我想只顯示一次彈出窗口,當頁面被加載,沒有它不斷顯示。

股利,其中包含彈出:

<div id="popup_load" class="popup_block"> 
<b>Lorem ipsum dolores sit amet</b> 
</div> 

腳本

<script type="text/javascript"> 
$(document).ready(function(){ 

    $.fn.popOpen = function(){ 

     var popID = $(this).attr('rel'); //Get Popup Name 
     var popURL = $(this).attr('href'); //Get Popup href to define size 

     //Pull Query & Variables from href URL 
     var query= popURL.split('?'); 
     var dim= query[1].split('&'); 
     var popWidth = dim[0].split('=')[1]; //Gets the first query string value 


     //Fade in the Popup and add close button 
     $('#' + popID).fadeIn('slow').css({ 'width': Number(popWidth) }).prepend('<a href="#" class="close"><img src="images/close.png" class="btn_close" title="<?php echo $lang['sluit'] ?>" /></a>'); 

     //Define margin for center alignment (vertical horizontal) - we add 80px to the height/width to accomodate for the padding and border width defined in the css 
     var popMargTop = ($('#' + popID).height() + 20)/2; 
     var popMargLeft = ($('#' + popID).width() + 20)/2; 

     //Apply Margin to Popup 
     $('#' + popID).css({ 
      'margin-top' : -popMargTop, 
      'margin-left' : -popMargLeft 
     }); 

     //Fade in Background 
     $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag. 
     $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 
    }; 

    $('a.poplight[href=#?w=400]').popOpen(); //Run popOpen function once on load 

    //Close Popups and Fade Layer 
    //$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer... 
    $('a.close').live('click', function() { //When clicking on the close... 
     $('#fade , .popup_block').fadeOut(function() { 
      $('#fade, a.close').remove(); //fade them both out 
      location.reload(); // reload page 
     }); 
     return false; 
    }); 

    popOpen 
}); 
</script> 
+0

那是一個錯字? pop打開標籤前的最後一行 – Vikram 2012-08-03 19:38:13

回答

0

您點擊一個實際的鏈接關閉彈出窗口,至少可能包含#號作爲href,這會導致瀏覽器重新加載頁面。嘗試這樣的事情對你關閉功能

$('a.close').live('click', function(e) { //When clicking on the close... 
     e.preventDefault(); 
     $('#fade , .popup_block').fadeOut(function() { 
      $('#fade, a.close').remove(); //fade them both out 
      location.reload(); // reload page 
     }); 
     return false; 
    }); 

這可以防止做它的默認操作的鏈接,並應引起彈出窗口顯示只有一次在加載

0

設置cookie當您第一次顯示你的彈出窗口。然後在再次顯示之前,請在顯示之前檢查cookie是否存在。

$(document).ready(function(){ 
    if (cookie is set){ 
     return ; 
    } 

    show cookie code 

    then mark cookie as set 
});