举例如下

// 通用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

相关文章:

  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2021-10-03
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
猜你喜欢
  • 2018-05-16
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
相关资源
相似解决方案