---
title: "ｅｘｔｊｓ\u3000ｄｅｂｕｇ"
author: "Darlyn"
date: "2014-01-03T15:46:46Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2014-01-03T15:45:30Z"
id: 1998725
url: "https://darlyn.iteye.com/blog/1998725"
---

extjs新引进了ｂｏｏｔｓｔｒａｐ　可以在其中定义是否ｄｅｂｕｇ和用什么文件ｄｅｂｕｇ

```javaｓｃript

(function() {
    var scripts = document.getElementsByTagName('script'),
        localhostTests = [
            /^localhost$/,     /*用于匹配以ｌｏｃａｌｈｏｓｔ开头的ｕｒｌ*/
            /\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:\d{1,5})?\b/ // IP v4
        ],
        host = window.location.hostname,　　　/*服务器自带的ｈｏｓｔｎａｍｅ有的是ｈｏｓｔ有的是ｌｏｃａｌｈｏｓｔ*/
        isDevelopment = null,
        queryString = window.location.search,
        test, path, i, ln, scriptSrc, match;

    for (i = 0, ln = scripts.length; i < ln; i++) {
        scriptSrc = scripts[i].src;

        match = scriptSrc.match(/bootstrap\.js$/);

        if (match) {
            path = scriptSrc.substring(0, scriptSrc.length - match[0].length);
            break;
        }
    }

    if (queryString.match('(\\?|&)debug') !== null) {
        isDevelopment = true;　　/*如果url后缀有'?'＋debug则为询问字符串，设isDevelopment为true*/
    }else if (queryString.match('(\\?|&)nodebug') !== null) {
        isDevelopment = false;  /*如果url后缀有'?'＋nodebug则为false*/
    }

    if (isDevelopment === null) {
        for (i = 0, ln = localhostTests.length; i < ln; i++) {
            test = localhostTests[i];

            if (host.search(test) !== -1) {
                isDevelopment = true;
                break;
            }
        }
    }

    if (isDevelopment === null && window.location.protocol === 'file:') {
        isDevelopment = true;
    }
/*如果都不符合以上两个判定，且isDevelopment为null或url是由“file：”开头即允许以文件形式打开自动进行debug*/
    document.write('<script type="text/javascript" charset="UTF-8" src="' + 
        path + 'ext-4/ext-all' + (isDevelopment ? '-debug' : '') + '.js"></script>'); /*这里是配置ext-all-debug的路径*/
})();

```

－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－


浏览器中的header：
浏览器中的header配置了request和response分别记录了浏览器向服务器发出请求时发出信息的类型，状态及request的方法＝>get或post；和服务器向浏览器返回的信息的类型和状态。
如果request是get方法，则可以通过在url后加name=value的方式传递参数，post方法一般在传递信息安全性要求较高或信息量比较大时使用。

示例：

```text

Request URL:http://localhost:8080/ExtjsMVC/account_manager/app/app.js
Request Method:GET
Status Code:304 Not Modified  //静态文件未修改
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch  //接受文件类型
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:localhost:8080
If-Modified-Since:Fri, 03 Jan 2014 02:53:35 GMT
If-None-Match:W/"434-1388717615724"
Referer:http://localhost:8080/ExtjsMVC/account_manager/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
Response Headersview source
Date:Fri, 03 Jan 2014 03:02:20 GMT
ETag:W/"434-1388717615724"
Server:Apache-Coyote/1.1   

```