2

我试图this.hrefbeforeShow块中覆盖,但它不起作用。的旧值this.href即使被覆盖也会被使用。

代码是:

beforeShow: function (opts, fb_obj) {

    // this conditional is some other code checking $(window).width() and $(window).height() and
    // if the bigger image will fit; it is simplified here!
    if (1) {
        var source = this.href;
        this.href = source.replace('_large','_super_large');
        console.log('retina detacted! ' + source + " " + this.href);
        // console output is OK, but this.href is not beeing replaced in the output!
}
4

2 回答 2

1

如果要覆盖 的值this.href,请beforeLoad改用。

注意:这是为 fancybox v2.0.6+

于 2012-07-30T07:04:50.103 回答
0

既然你在 jquery 中标记了这个 ..ill say

完整代码

if (1) {
         var oldhref = $(this).attr('href');
        $(this).attr('href','_super_large');
        console.log('retina detacted! ' +oldhref + " " + this.attr('href');
}
于 2012-07-30T06:33:32.567 回答