• js 配置基础启动文件


    页面启动文件boot.js,获取存放该文件的路径,放置通用的css,js代码,方便html页面调用。

    __CreateJSPath = function (js) {
        var scripts = document.getElementsByTagName("script");
        var path = "";
        for (var i = 0, l = scripts.length; i < l; i++) {
            var src = scripts[i].src;
            if (src.indexOf(js) != -1) {
                var ss = src.split(js);
                path = ss[0];
                break;
            }
        }
        var href = location.href;
        href = href.split("#")[0];
        href = href.split("?")[0];
        var ss = href.split("/");
        ss.length = ss.length - 1;
        href = ss.join("/");
        if (path.indexOf("https:") == -1 && path.indexOf("http:") == -1 && path.indexOf("file:") == -1 && path.indexOf("/") != 0) {
            path = href + "/" + path;
        }
        return path;
    }
    var bootPATH = __CreateJSPath("boot.js");
    var basePATH =bootPATH.split("/")[0]+"/"+ bootPATH.split("/")[2]+"/";
    document.write('<link href="' + bootPATH + 'bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />');
    document.write('<script src="' + bootPATH + 'jquery/jquery.min.js" type="text/javascript"></sc' + 'ript>');
    document.write('<script src="' + bootPATH + 'bootstrap/js/bootstrap.js" type="text/javascript" ></sc' + 'ript>');
    document.write('<script src="' + bootPATH + 'app/js/base.js"" type="text/javascript" ></sc' + 'ript>');
    document.write('<script src="' + bootPATH + 'jquery/json2.js"" type="text/javascript" ></sc' + 'ript>');

    项目文件结构:(如下图)

    bootPATH 就等于http://localhost:12514/Component/这个路径

    html页面调用代码:

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <script src="../../boot.js" type="text/javascript"></script>
    </head>


     

  • 相关阅读:
    广搜 BFS()
    最短路-A
    DFS-C
    codeforces contest
    小技巧
    将博客搬至CSDN
    建树
    codeforces gym102411 Equidistant(图论+乱搞)
    codeforces 1250N wires(简单图论)
    Splay 树
  • 原文地址:https://www.cnblogs.com/lizeyan/p/3508917.html
Copyright © 2020-2023  润新知