[英]how to show/open colorbox only in specific pages
i have a common.js library that give all the javascript code i need for my site from one file. 我有一个common.js库,它从一个文件中提供了我的网站所需的所有javascript代码。 The thing is that i have the following code in that file and is opening in every page but i need to open in only when the visiotr opening a specific page.
事情是,我在该文件中有以下代码,并且正在每个页面中打开,但是只有在打开特定页面的时候才需要打开。
// 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',
});
}
};
Set a value only on those pages that you want the color box to open on. 仅在要打开颜色框的页面上设置一个值。
There are many different values you can set and check.. 您可以设置和检查许多不同的值。
body
element. body
元素上的类名称。 data-*
attribute on the body element data-*
属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.