我是靠谱客的博主 忐忑哈密瓜,这篇文章主要介绍如何将其他页面都引用的js提取到公共的一个js,现在分享给大家,希望可以做个参考。

举例如下

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// 通用js和css (function (){ var strFullPath=window.document.location.href; var strPath=window.document.location.pathname; var pos=strFullPath.indexOf(strPath); var prePath=strFullPath.substring(0,pos); var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1); var appRootPath = prePath+postPath; var jsHeader = "<script type='text/javascript' src='" + appRootPath + "/"; var jsFooter = "'></script>"; document.write(jsHeader + "common/js/jquery-1.12.3.js" + jsFooter); document.write(jsHeader + "common/js/common.js" + jsFooter); document.write(jsHeader + "layui/src/layui.js" + jsFooter); document.write(jsHeader + "layui/src/layui-xtree.js" + jsFooter); document.write(jsHeader + "common/js/page_util.js" + jsFooter); document.write(jsHeader + "common/js/date_util.js" + jsFooter); document.write(jsHeader + "common/js/dateConvert.js" + jsFooter); var cssHeader = "<link rel='stylesheet' type='text/css' href='" + appRootPath + "/"; var cssFooter = "'></link>"; document.write(cssHeader + "layui/src/css/layui_1366.css" + cssFooter); document.write(cssHeader + "common/js/common.css" + cssFooter); })();

2.其他页面用这个js就还可以了

最后

以上就是忐忑哈密瓜最近收集整理的关于如何将其他页面都引用的js提取到公共的一个js的全部内容,更多相关如何将其他页面都引用内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(96)

评论列表共有 0 条评论

立即
投稿
返回
顶部