문제

I would like to know the value of a var by using firebug. I know the way to get them with console.log or alert. In my case I can't change the code to add something. Is there a way to read a var without changing code by firebug?

I made a fiddle: http://jsfiddle.net/JdEvU/2/

Is there a possibilitie to get/see the value of targetPosition in firebug?

function handleWheel(evt){
    var e = window.event || evt; // old IE support
    var delta = -e.wheelDelta || (40 * e.detail);
    console.log('I am awake');
    advance(delta);

}

    function advance(delta){
    direction = (Math.abs(delta) > 2) ? ((delta > 0) ? 1 : -1) : ((delta < 0) ? 1 : -1);
    var targetPosition = delta * 5;
    console.log('delta: ',delta);    
   }



// Events
function addEvent(evt, handler, element){
    if(window.addEventListener){
        if(evt == 'mousewheel'){
            // Firefox
            element.addEventListener("DOMMouseScroll", handler, false);
        }
        element.addEventListener(evt, handler, false);
    }
    else if (window.attachEvent)
        element.attachEvent('on' + evt, handler);
}

addEvent('mousewheel', handleWheel, window);
도움이 되었습니까?

해결책

It's a local variable, so I guess the only possibility is to use the debugger here. To do so add a breakpoint on next line and add targetPosition to the watched variables. As soon as the line is executed the script execution will stop at it and you'll be able to see the value.

enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top