Javascript 如何在beforeShow块中覆盖this.href?(jquery/fancybox)
我试图覆盖Javascript 如何在beforeShow块中覆盖this.href?(jquery/fancybox),javascript,jquery,fancybox,Javascript,Jquery,Fancybox,我试图覆盖beforeShow块中的this.href,但它不起作用。 即使覆盖了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 simpli
beforeShow
块中的this.href
,但它不起作用。
即使覆盖了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!
}
因为你在jquery中标记了这个..我说 完整代码
if (1) {
var oldhref = $(this).attr('href');
$(this).attr('href','_super_large');
console.log('retina detacted! ' +oldhref + " " + this.attr('href');
}
如果要覆盖
this.href
的值,请改用加载前
注意:这是为fancybox v2.0.6+设计的!images/uploads/_large/0240.jpg images/uploads/_super_large/0240.jpg此操作不会生效,因为内容已加载。在加载之前使用