在我的网站上,几秒钟后会出现一个花哨的框弹出窗口,询问用户他是否想注册通讯。这工作正常。通过普通文字链接打开fancybox
但是,我也想在网页上放一个链接,以便打开时事通讯栏。我试过Click <a href="#newsletterpopup">here</a> to open the popup
。没有成功。
非常感谢您的帮助
JS:
function openFancybox() {
setTimeout(function() {
$.fancybox('#newsletterpopup', {
closeClick: false, // this prevents fancybox to close unless close unless ".non-merci" is clicked
showCloseButton: true,
helpers: {
overlay: {
css: {
'background': 'rgba(58, 42, 45, 0.3)'
}
}
},
afterShow: function() {
// enables a way to close fancybox
$(".non-merci").on("click", function() {
$.fancybox.close()
});
}
});
}, 7000);
};
$(document).ready(function() {
var visited = $.cookie('visited');
if (visited == 'yes') {
return false;
} else {
openFancybox();
}
$.cookie('visited', 'yes', {
expires: 0.04
});
});
非关联脚本,可能导致与点击功能冲突:
//==============
//! Smooth scrolling/click potentially conflicting with other scripts
//==============
$(document).ready(function(e) {
$('a[href*=#]:not([href=#])').click(function (ev) { // Added 'ev' parameter
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
ev.preventDefault(); // We're animating this, so don't let the browser try to navigate to this URL
$('html,body').animate({
scrollTop: target.offset().top - 100
}, 'normal');
}
}
});
window.onscroll = scrollFunction;
function scrollFunction() {
var doc = document.documentElement, body = document.body;
var top = (doc && doc.scrollTop || body && body.scrollTop || 0);
if (top > 200) {
$('.back-to-top').fadeIn();
}
else {
$('.back-to-top').fadeOut();
}
}
});
你的小提琴显示错误'undefined不是一个函数'。尝试先纠正它。 – j809