2014-03-28 55 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元素上的属性
  • 配置对象,特定于每个页面。
相关问题