Question

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);
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top