在我的網站上,幾秒鐘後會出現一個花哨的框彈出窗口,詢問用戶他是否想註冊通訊。這工作正常。通過普通文字鏈接打開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