多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 采用jquery的方法载入网页的公共的部分时,页面刷新之时公共部分出现了闪烁 ## 解决方案 ### 将公共部分编译为js代码 [链接](http://tool.chinaz.com/Tools/Html_Js.aspx) ``` function writeDom() { document.writeln(""); document.writeln(" "); document.writeln(" 山东省学校创客空间服务平台"); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" 个人中心"); document.writeln(" "); document.writeln(" "); document.writeln(" 退出登录"); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" 首页"); document.writeln(" —"); document.writeln(" 报名进度"); document.writeln(" —"); document.writeln(" 赛事中心"); document.writeln(" —"); document.writeln(" 消息中心"); document.writeln(" —"); document.writeln(" 大赛指南"); document.writeln(" —"); document.writeln(" 项目说明"); document.writeln(" —"); document.writeln(" 结果公示"); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); document.writeln(" "); } writeDom() ``` ### 在页面的公共部分引入j ``` <div id\='Head' class\="public\_top" style\="height: 236px"> <script src='./s.js'></script> </div> ``` ### 解决导航高亮的问题 ``` /\* @pageName : 当前页面的name \*/ function currentPage(pageName) { if (!pageName || typeof (pageName) != 'string') { throw new Error('当前页面不存在或参数格式不正确'); } switch (pageName) { case 'competeCenter': $("#Nav a:eq(2)").addClass('current\_nav').siblings().removeClass('current\_nav'); $("#Nav a:eq(0)").addClass('current\_nav'); break; case 'informationCenter': $("#Nav a:eq(3)").addClass('current\_nav').siblings().removeClass('current\_nav'); $("#Nav a:eq(0)").addClass('current\_nav'); break; case 'personalCenter': $("#Nav a:eq(0)").addClass('current\_nav').siblings().removeClass('current\_nav'); $("#Nav a:eq(0)").addClass('current\_nav'); console.log('当前页面是个人中心页面'); break; case 'signUpProgress': console.log($('#Nav a:eq(1)')) $("#Nav a:eq(1)").addClass('current\_nav').siblings().removeClass('current\_nav'); $("#Nav a:eq(0)").addClass('current\_nav'); break; case 'systemInformation': $("#Nav a:eq(3)").addClass('current\_nav').siblings().removeClass('current\_nav'); $("#Nav a:eq(0)").addClass('current\_nav'); break; default: } } ```