Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用web开发人员工具正确检查jquery和javascript?_Javascript_Jquery_Html_Css_Web Developer Toolbar - Fatal编程技术网

如何使用web开发人员工具正确检查jquery和javascript?

如何使用web开发人员工具正确检查jquery和javascript?,javascript,jquery,html,css,web-developer-toolbar,Javascript,Jquery,Html,Css,Web Developer Toolbar,我试图使用web开发工具检查web页面上的java脚本,但我发现很难看到站点的哪些部分正在使用JS 与CSS或HTML不同,您可以看到站点使用这些语言的每个部分 当我设法找到任何JS时,我会尝试删除其中的一些,但它似乎不会改变站点的功能(不像更改CSS或HTML时) 有没有简单的方法可以检测、提取、测试和评估站点的javascript,并查看站点的哪个部分正在使用特定的脚本 下面是一个具体的例子: 有一个站点有一个名为jquery.parallax的jquery库: 检查图像的html和css时

我试图使用web开发工具检查web页面上的java脚本,但我发现很难看到站点的哪些部分正在使用JS

与CSS或HTML不同,您可以看到站点使用这些语言的每个部分

当我设法找到任何JS时,我会尝试删除其中的一些,但它似乎不会改变站点的功能(不像更改CSS或HTML时)

有没有简单的方法可以检测、提取、测试和评估站点的javascript,并查看站点的哪个部分正在使用特定的脚本

下面是一个具体的例子:

有一个站点有一个名为jquery.parallax的jquery库:

检查图像的html和css时,您会得到:

<div class="parallax-viewport" id="parallax">

        <!-- parallax layers -->
        <div class="parallax-layer" style="width: 860px; height: 273px; top: 77.08854166666667%; margin-top: -210.45171875px; left: 0%; margin-left: 0px;">
            <img src="images/parallax_sketch/0_sun.png" alt="" style="position:absolute; left:300px; top:-12px;">
        </div>
        <div class="parallax-layer" style="width: 920px; height: 274px; top: 77.08854166666667%; margin-top: -211.22260416666666px; left: 0%; margin-left: 0px;">
            <img src="images/parallax_sketch/1_mountains.png" alt="">
        </div>
        <div class="parallax-layer" style="width: 1100px; height: 284px; top: 77.08854166666667%; margin-top: -218.93145833333332px; left: 0%; margin-left: 0px;">
            <img src="images/parallax_sketch/2_hill.png" alt="" style="position:absolute; top:40px; left:0;">
        </div>
        <div class="parallax-layer" style="width: 1360px; height: 320px; top: 77.08854166666667%; margin-top: -246.68333333333334px; left: 0%; margin-left: 0px;">
            <img src="images/parallax_sketch/3_wood.png" alt="" style="position:absolute; top:96px; left:0;">
        </div>

        <!-- Rounded corners -->
        <img src="http://stephband.info/images/corner_white_tl.png" class="tl">
        <img src="http://stephband.info/images/corner_white_tr.png" class="tr">
        <img src="http://stephband.info/images/corner_white_bl.png" class="bl">
        <img src="http://stephband.info/images/corner_white_br.png" class="br">
    </div

**OK, now there is a specific jquery file that controls the parallax function:**

// jquery.jparallax.js
// 1.0
// Stephen Band
//
// Project and documentation site:
// webdev.stephband.info/jparallax/
//
// Repository:
// github.com/stephband/jparallax
//
// Dependencies:
// jquery.event.frame
// webdev.stephband.info/events/frame/

(function(jQuery, undefined) {

    // Plugin name
    var plugin = "parallax";

    // VAR

    var options = {
            mouseport:  'body',    // jQuery object or selector of DOM node to use as mouse detector
            xparallax:  true,      // boolean | 0-1 | 'npx' | 'n%' - Sets axis of reaction and by how much they react
            yparallax:  true,      //
            xorigin:        0.5,       // 0-1 - Sets default alignment. Only has effect when parallax values are something other than 1 (or true, or '100%')
            yorigin:        0.5,       //
            decay:          0.66,      // 0-1 (0 instant, 1 forever) - Sets rate of decay curve for catching up with target mouse position
            frameDuration:  30,    // Int (milliseconds)
            freezeClass:    'freeze' // String - Class added to layer when frozen
        },

        value = {
            left: 0,
            top: 0,
            middle: 0.5,
            center: 0.5,
            right: 1,
            bottom: 1
        },

        regex = {
            px:         /^\d+\s?px$/,
            percent:    /^\d+\s?%$/
        },

        frameEvent = 'frame.'+plugin,

        abs = Math.abs,

        pointer = [0, 0];

    // FUNCTIONS

    function parseValue(value) { return this.lib[value]; }
    parseValue.lib = value;

    // Converts numbers or numbers in strings to boolean
    function parseBool(x) {
        return typeof x === "boolean" ? x : !!( parseFloat(x) ) ;
    }

    function parseCoord(x) {
        return (regex.percent.exec(x)) ? parseFloat(x)/100 : x;
    }

    // CONSTRUCTORS

    function Mouse(xparallax, yparallax, decay, pointer){

        // Convert parallax options to boolean values
        var parallax = [xparallax, yparallax];

        this.ontarget = false;
        this.decay = decay;
        this.pointer = pointer || [0.5, 0.5];
        this.update = function(pointer, threshold){
            var lagPointer, x;

            // Pointer is already on target
            if (this.ontarget) {
                this.pointer = pointer;
            }

            // Pointer has arrived within the target thresholds
            else if ((!parallax[0] || abs(pointer[0] - this.pointer[0]) < threshold[0]) &&
                    (!parallax[1] || abs(pointer[1] - this.pointer[1]) < threshold[1])) {
                this.ontarget = true;
                this.pointer = pointer;
            }

            // Pointer is nowhere near the target
            else {
                lagPointer = [];
                x = 2;

                while (x--) {
                    if ( parallax[x] ) {
                        lagPointer[x] = pointer[x] + this.decay * (this.pointer[x] - pointer[x]);
                    }
                }

                this.pointer = lagPointer;
            }
        };
    }

    function Port(object, options){
        var self = this,
            elem = object instanceof jQuery ? object : jQuery(object) ,
            // Convert parallax options to boolean values
            parallax = [parseBool(options.xparallax), parseBool(options.yparallax)],
            // State of mouse position (0 - outside, 1 - inside, 2 - just gone outside)
            inside = 0,
            // Stores mouse position on mouseleave event
            leaveCoords;

        this.pointer = [0, 0];
        this.active = false;
        this.activeOutside = (options && options.activeOutside) || false;
        this.update = function(coords){
            var pos = this.pos,
                size = this.size,
                pointer = [],
                x = 2;

            // Is mouse inside port?
            // Yes.
            if ( inside > 0 ) {
                // But it just went outside, so make this the last move
                // Use leaveCoords stored by mouseleave event
                if ( inside === 2 ) {
                    inside = 0;
                    if (leaveCoords) {
                        coords = leaveCoords
                    };
                }

                while (x--) {
                    if ( parallax[x] ) {
                        pointer[x] = (coords[x] - pos[x]) / size[x] ;
                        pointer[x] = pointer[x] < 0 ? 0 : pointer[x] > 1 ? 1 : pointer[x] ;
                    }
                }

                this.active = true;
                this.pointer = pointer;
            }
            // No.
            else {
                this.active = false;
            }
        };
        this.updateSize = function(){
            var width = elem.width(),
                height = elem.height();

            self.size = [width, height];
            self.threshold = [ 1/width, 1/height ];
        };
        this.updatePos = function(){
            var offset = elem.offset() || {left: 0, top: 0},
                left = parseInt(elem.css('borderLeftWidth')) + parseInt(elem.css('paddingLeft')),
                top = parseInt(elem.css('borderTopWidth')) + parseInt(elem.css('paddingTop'));

            self.pos = [offset.left + left, offset.top + top];
        };

        // Update mouseport dimensions on window resize
        jQuery(window)
        .bind('resize.'+plugin, self.updateSize)
        .bind('resize.'+plugin, self.updatePos);

        // Detect entry and exit of mouse
        elem
        .bind('mouseenter.'+plugin, function(e){
            inside = 1;
        })
        .bind('mouseleave.'+plugin, function(e){
            inside = 2;
            leaveCoords = [e.pageX, e.pageY];
        });

        // Set up layer
        this.updateSize();
        this.updatePos();
    }

    function Layer(elem, options){
        var px = [],
            parallax = [],
            offset = [],
            position = [];

        this.update = function(pointer){
            var pos = [],
                cssPosition,
                cssMargin,
                x = 2,
                css = {};

            while (x--) {
                if ( parallax[x] ) {
                    pos[x] = parallax[x] * pointer[x] + offset[x];

                    // We're working in pixels
                    if ( px[x] ) {
                        cssPosition = position[x];
                        cssMargin = pos[x] * -1;
                    }
                    // We're working by ratio
                    else {
                        cssPosition = pos[x] * 100 + '%';
                        cssMargin = pos[x] * this.size[x] * -1;
                    }

                    // Fill in css object
                    if ( x === 0 ) {
                        css.left = cssPosition;
                        css.marginLeft = cssMargin;
                    }
                    else {
                        css.top = cssPosition;
                        css.marginTop = cssMargin;
                    }
                }
            }

            // Set css
            elem.css(css);
        };

        this.setParallax = function(xp, yp, xo, yo){
            var p = [ xp || options.xparallax, yp || options.yparallax ],
                origin = [ xo || options.xorigin, yo || options.yorigin ],
                i = 2,
                css = {};

            while (i--) {
                // Set px flag
                px[i] = regex.px.test(p[i]);

                // Convert origin to numbers
                if (typeof origin[i] === 'string') {
                    origin[i] = origin[i] === undefined ? 1 :
                                value[ origin[i] ] || parseCoord(origin[i]) ;
                }

                // We're dealing with pixel dimensions
                if ( px[i] ) {
                    // Set parallax
                    parallax[i] = parseInt(p[i]);

                    // Set offset
                    offset[i] = origin[i] * ( this.size[i] - parallax[i] );

                    // Set css position constant
                    position[i] = origin[i] * 100 + '%';
                }

                // We're dealing with ratios
                else {
                    // Set parallax, converting to ratio where necessary
                    parallax[i] = p[i] === true ? 1 : parseCoord(p[i]);

                    // Set offset
                    offset[i] = parallax[i] ? origin[i] * ( 1 - parallax[i] ) : 0 ;
                }
            }
        };

        this.getPointer = function(){
            var viewport = elem.offsetParent(),
                pos = elem.position(),
                position = [],
                pointer = [],
                i = 2;

            // Reverse calculate ratio from layer's current position
            while (i--) {
                if ( px[i] ) {
                    // TODO: reverse calculation for pixel case
                    position[i] = 0;
                }
                else {
                    position[i] = pos[ i === 0 ? 'left' : 'top' ] / (viewport[ i === 0 ? 'outerWidth' : 'outerHeight' ]() - this.size[i]) ;
                }

                pointer[i] = (position[i] - offset[i]) / parallax[i] ;
            }

            return pointer;
        };

        this.setSize = function(x, y){
            this.size = [ x || elem.outerWidth(), y || elem.outerHeight() ];
        };

        this.setSize(options.width, options.height);
        this.setParallax(options.xparallax, options.yparallax, options.xorigin, options.yorigin);
    }

    // EVENT HANDLERS

    function update(e){

        var elem = jQuery(this),
            global = e.data.global || e.data,
            local = e.data.local || elem.data(plugin),
            port = global.port,
            mouse = global.mouse,
            localmouse = local.mouse,
            process = global.timeStamp !== e.timeStamp;

        // Global objects have yet to be processed for this frame
        if ( process ) {
            // Set timeStamp to current time
            global.timeStamp = e.timeStamp;

            // Process mouseport
            port.update(pointer);

            // Process mouse
            if ( port.active || !mouse.ontarget ) {
                mouse.update(port.pointer, port.threshold);
            }
        }

        // Layer has it's own mouse
        if ( localmouse ) {

            // Process mouse
            localmouse.update( local.freeze ? local.freeze.pointer : port.pointer, port.threshold );

            // If it hits target
            if ( localmouse.ontarget ) {

                delete local.mouse;

                // Stop animating frozen layers
                if (local.freeze) {
                    elem
                    .unbind(frameEvent)
                    .addClass(global.freezeClass);
                }
            }

            // Use localmouse in place of mouse
            mouse = localmouse;
        }
        // Layer is responding to global mouse
        else {
            // When no longer active, unbind
            if ( mouse.ontarget && !port.active ) {
                elem.unbind(frameEvent);
            }
        }

        local.layer.update(mouse.pointer);
    }

    jQuery.fn[plugin] = function(o){
        var global = jQuery.extend({}, jQuery.fn[plugin].options, o),
            args = arguments,
            layers = this,
            optionsArray = [];

        if (undefined === jQuery.event.special.frame) {
            throw "jquery.parallax requires jquery.event.frame.";
        }

        // Turn mouseport into jQuery obj
        if ( !(global.mouseport instanceof jQuery) ) {
            global.mouseport = jQuery(global.mouseport); 
        }

        global.port = new Port(global.mouseport, global);
        global.mouse = new Mouse(parseBool(global.xparallax), parseBool(global.yparallax), global.decay);

        global.mouseport
        .bind("mouseenter", function(e){
            var i = layers.length,
                layer;

            global.mouse.ontarget = false;

            // Animate unfrozen layers
            while (i--) {
                layer = layers[i];

                if (!jQuery.data(layer, plugin).freeze) {
                    jQuery.event.add(this, frameEvent, update, {
                        global: global,
                        local: optionsArray[i]
                    });
                };
            }
        });

        return layers.each(function(i){
            var elem = jQuery(this),

                // Construct layer options from extra arguments
                layerOptions = args[i+1] ? jQuery.extend({}, global, args[i+1]) : global ,

                // Set up layer data. Give it a local mouse 
                // initialises it to start smoothly from current position
                layer = new Layer(elem, layerOptions),
                local = {
                    layer: layer,
                    mouse: new Mouse(parseBool(layerOptions.xparallax), parseBool(layerOptions.yparallax), layerOptions.decay, layer.getPointer())
                };

            elem.data(plugin, local);
            optionsArray.push(local);

            // Bind freeze and unfreeze actions directly to layers using
            // jQuery.event.add(node, type, fn, data)

            jQuery.event.add(this, 'freeze', function(e){
                var elem = jQuery(this),
                    global = e.data.global,
                    local = e.data.local,
                    mouse = local.mouse || local.freeze || global.mouse,
                    coords = coords = [
                        e.x === undefined ? mouse.pointer[0] : parseCoord(e.x),
                        e.y === undefined ? mouse.pointer[1] : parseCoord(e.y)
                    ],
                    decay = e.decay;

                // Store position
                local.freeze = { pointer: coords };

                // Create local mouse, passing in current pointer with options
                local.mouse = new Mouse(parseBool(global.xparallax), parseBool(global.yparallax), global.decay, mouse.pointer);

                if (decay !== undefined) { local.mouse.decay = decay; }

                // Start animating
                jQuery.event.add(this, frameEvent, update, global);
            }, {
                global: global,
                local: local
            });

            jQuery.event.add( this, 'unfreeze', function(e){
                var elem = jQuery(this),
                    global = e.data.global,
                    local = e.data.local,
                    decay = e.decay,
                    pointer;

                if (!local.freeze) { return; }

                // Create local mouse, passing local freeze pointer with options
                pointer = local.mouse ? local.mouse.pointer : local.freeze.pointer ;
                local.mouse = new Mouse(parseBool(global.xparallax), parseBool(global.yparallax), global);
                local.mouse.pointer = pointer;

                // Override decay with decay passed as e.decay
                if (decay !== undefined) local.mouse.decay = decay;

                // Destroy local.freeze
                delete local.freeze;

                // Remove freeze class and start animating
                elem.removeClass(options.freezeClass);

                // Start animating
                jQuery.event.add(this, frameEvent, update, global);
            }, {
                global: global,
                local: local
            });
        });
    };

    // EXPOSE

    jQuery.fn[plugin].options = options;

    // RUN

    jQuery(document).ready(function(){
        // Pick up and store mouse position on jQuery(document)
        // IE does not register mousemove on jQuery(window)
        jQuery(document)
        .mousemove(function(e){
            pointer = [e.pageX, e.pageY];
        });
    });

`enter code here`}(jQuery));

0 ) {
//但它只是出去了,所以这是最后一步
//使用mouseleave事件存储的leaveCoords
如果(内部===2){
内=0;
如果(离开Coords){
coords=leaveCoords
};
}
而(x-){
if(视差[x]){
指针[x]=(坐标[x]-pos[x])/size[x];
指针[x]=指针[x]<0?0:指针[x]>1?1:指针[x];
}
}
this.active=true;
this.pointer=指针;
}
//没有。
否则{
this.active=false;
}
};
this.updateSize=函数(){
变量宽度=元素宽度(),
高度=元素高度();
self.size=[宽度、高度];
self.threshold=[1/宽度,1/高度];
};
this.updatePos=函数(){
var offset=elem.offset(),
left=parseInt(elem.css('borderLeftWidth'))+parseInt(elem.css('paddingLeft')),
top=parseInt(elem.css('borderTopWidth'))+parseInt(elem.css('paddingTop'));
self.pos=[offset.left+left,offset.top+top];
};
//在调整窗口大小时更新鼠标点尺寸
jQuery(窗口)
.bind('resize.'+插件,self.updateSize)
.bind('resize.'+插件,self.updatePos);
//检测鼠标的进入和退出
元素
.bind('mouseenter.'+插件,函数(e){
内=1;
})
.bind('mouseleave.'+插件,函数(e){
内=2;
leaveCoords=[e.pageX,e.pageY];
});
//设置层
this.updateSize();
this.updatePos();
}
功能层(元素、选项){
var px=[],
视差=[],
偏移量=[],
位置=[];
this.update=函数(指针){
var pos=[],
CSP位置,
斯马金,
x=2,
css={};
而(x-){
if(视差[x]){
pos[x]=视差[x]*指针[x]+偏移[x];
//我们在用像素工作
if(px[x]){
cssPosition=位置[x];
cssMargin=pos[x]*-1;
}
//我们是按比例工作的
否则{
cssPosition=pos[x]*100+'%';
cssMargin=pos[x]*此.size[x]*-1;
}
//填充css对象
如果(x==0){
css.left=cssposposition;
css.marginLeft=cssMargin;
}
否则{
css.top=cssposposition;
css.marginTop=cssMargin;
}
}
}
//设置css
元素css(css);
};
this.setParallax=函数(xp,yp,xo,yo){
var p=[xp | | options.xparallax,yp | | options.yparallax],
原点=[xo | | options.xorigin,yo | | options.yorigin],
i=2,
css={};
而(我--){
//设置px标志
px[i]=正则表达式px.test(p[i]);
//将原点转换为数字
if(原点类型[i]=“字符串”){
原点[i]=原点[i]==未定义?1:
值[origin[i]| | parseCoord(origin[i]);
}
//我们在处理像素尺寸
if(px[i]){
//设置视差
视差[i]=parseInt(p[i]);
//设置偏移量
偏移量[i]=原点[i]*(此.size[i]-视差[i]);
//设置css位置常量
位置[i]=原点[i]*100+'%';
}
//我们正在处理比率问题
否则{
//设置视差,必要时转换为比率
视差[i]=p[i]==true?1:parseCoord(p[i]);
//设置偏移量
偏移量[i]=视差[i]?原点[i]*(1-视差[i]):0;
}
}
};
this.getPointer=函数(){
var viewport=elem.offsetParent(),
位置=元素位置(),
位置=[],
指针=[],
i=2;
//从层的当前位置反向计算比率
而(我--){
if(px[i]){
//TODO:反向c