【发布时间】:2013-04-09 17:45:41
【问题描述】:
我有一些类似的代码
var innerPage = {
/* declare vars, cache selectors */
leftWidth : $("#episodes-nav").width(),
right : $("#episodes-right"),
theWindow : $(window),
heroImageHolder : $("#hero-image-holder"),
heroImage : $("#hero-image"),
whiteOverlay : $("#white-overlay"),
tilesContainer : $("#tiles-container"),
heroPercentToShow : 0.6,
// heroHolderWidth : this.heroImageHolder.width(),
// heroHolderHeight : this.heroImageHolder.height(),
heroImgRealW : null,
heroImgRealH : null,
/* init */
init : function(){
var that = this;
this.heroImage.on('load', function(){
// image loaded .. do something
that.heroImgRealW = this.naturalWidth;
that.heroImgRealH = this.naturalHeight;
that.fitHeroImage();
that.buildInnerBlocks();
});
},
fitHeroImage : function(){
var desiredWidthToFit = this.heroPercentToShow * this.heroNaturalW;
var scaleRatio = this.heroViewportWidth / desiredWidthToFit;
//trace(scaleRatio);
this.heroImage.width( this.heroImage.width() * scaleRatio );
var offsetSides = (600 -this.heroImage.width() ) / 2;
var offsetTop = (containerHeight -this.heroImage.height() ) / 2;
//trace("top"+offsetTop);
this.heroImage.css("left", offsetSides);
this.heroImage.css("top", offsetTop);
this.heroImage.height( this.heroImage.height() * scaleRatio );
},
/* destroy */
destroy : function(){
},
/* sizeChildren */
sizeChildren : function(){
this.right.width( this.theWindow.width() - this.leftWidth );
this.whiteOverlay.width( this.right.width() - this.heroImageHolder.width() +2000 );
this.tilesContainer.width( this.whiteOverlay.width() );
this.fitHeroImage();
//$("#tiles-container").empty();
}
}
当我在函数或函数内部设置断点时,它们不会被触发(在 chrome 中测试)。我该如何解决?
【问题讨论】:
-
在代码中添加
debugger;看看是否有帮助。有时关闭浏览器并重新打开它会使断点神奇地工作。 -
您是否希望它在执行该函数之前在存储在对象中的函数中命中断点?
标签: javascript jquery debugging google-chrome