在Fancybox中更改URL,标题连同标题
问题描述:
我正在与Fancybox争执一番。在检查'alt'属性的状态后,我想更改图片的网址。在Fancybox中更改URL,标题连同标题
这里是我的代码:
$(document).ready(function() {
$(".fancybox").fancybox({
beforeShow : function() {
var now = new Date();
var month = now.getMonth() + 1;
var date = now.getDate();
var alt = this.element.find('img').attr('alt');
this.inner.find('img').attr('alt', alt);
if (month==11 && date >= alt){
this.title = alt+'. Dezember'}
else
{this.title = 'zu früh'
}
}
});
});
,对于标题正常工作。
现在,我想要另一个URL,而不是从调用href
收到的一个URL。
我已经试过这个'beforeLoad',它不起作用。此外,在这种情况下,Fancybox不会出现。
我错过了什么,或者做错了什么?
答
您仍然可以使用beforeLoad
和更改使用this.href
新地址的URL,因此对于这个网站:
<a class="fancybox fancybox.iframe" href="http://www.example.com">example</a>
使用脚本,如:
var picssel = true;
$(document).ready(function() {
$(".fancybox").fancybox({
beforeLoad: function() {
if (picssel && picssel === true) {
this.href = "http://picssel.com"
}
}
}); // fancybox
}); // document ready
这将改变基于URL在验证变量