2014-03-28 59 views
0

我有一個common.js庫,可以從一個文件中爲我的網站提供所需的所有javascript代碼。 事情是,我在該文件中有以下代碼,並打開每個頁面,但我需要打開時,只有當visiotr打開特定頁面。如何僅在特定頁面中顯示/打開colorbox

// open thickbox  
jQuery(document).ready(function($) {  
$('a.js-thickbox-subscribe').fcolorbox2();  
});  

$.fn.fcolorbox2 = function() {  
if (document.cookie.indexOf('visited=true') === -1) {  
    var expires = new Date();  
    expires.setDate(expires.getDate()+30);  
    document.cookie = "visited=true; expires="+expires.toUTCString();  
    $.colorbox({  
      inline:true,  
      overlayClose: false,  
      fixed: true,  
      href:'#test',  
      width:'700px',  
      height:'500px',  
     });  
}  
};  

回答

0

僅在希望打開顏色框的頁面上設置一個值。

有,你可以設置和檢查許多不同的值..

  • body元素的類名。
  • 一組Javascript變量。
  • A data-* body body元素上的屬性
  • 配置對象,特定於每個頁面。
相關問題