使用javaScript动态加载Js文件和Css文件
作者:lijiao 时间:2024-04-19 10:16:27
JS动态加载CSS 在可换主题的界面中具有很重要的意义,用户可以根据自己的浏览习惯选择自己喜欢的页面显示方式,下面详细说明。
希望下面的方法对你有帮助。
(1)使用JavaScript动态加载Js文件
/*JavaScript动态加载Js文件*/
var scriptNode = document.createElement('script');
scriptNode.src = 'proxy.js?t='+new Date().getTime();/*附带时间参数,防止缓存*/
document.head.appendChild(scriptNode);
(2)使用JavaScript动态加载css文件
/*JavaScript动态加载Css文件*/
var cssNode = document.createElement('link');
cssNode.rel = 'stylesheet';
cssNode.type = 'text/css';
cssNode.media = 'screen';
cssNode.href = 'style.css?t='+new Date().getTime();/*附带时间参数,防止缓存*/
document.head.appendChild(cssNode);
标签:js,css,javascript
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python manim实现排序算法动画示例
2021-11-10 10:41:58
![](https://img.aspxhome.com/file/2023/5/67865_0s.jpg)
PHP实现批量生成App各种尺寸Logo
2023-07-23 03:59:59
golang交叉编译详细
2024-05-02 16:26:31
![](https://img.aspxhome.com/file/2023/7/130707_0s.jpg)
OL IE Bug
2009-09-09 16:25:00
python用pickle模块实现“增删改查”的简易功能
2022-01-13 06:38:56
网页对联广告代码效果大全
2007-10-25 23:16:00
Dialog 按照顺序弹窗的优雅写法
2021-10-18 18:35:25
python实现3D地图可视化
2023-08-27 10:24:50
![](https://img.aspxhome.com/file/2023/6/81806_0s.jpg)
Python写出新冠状病毒确诊人数地图的方法
2022-09-28 06:15:13
![](https://img.aspxhome.com/file/2023/3/133433_0s.png)
用Python实现QQ游戏大家来找茬辅助工具
2021-09-10 16:28:44
![](https://img.aspxhome.com/file/2023/5/70705_0s.png)
python实现excel和csv中的vlookup函数示例代码
2021-05-06 07:22:48
![](https://img.aspxhome.com/file/2023/0/109850_0s.png)
asp如何制作一个搜索引擎链接程序?
2010-07-07 12:26:00
利用Python 实现分布式计算
2021-12-21 22:59:26
![](https://img.aspxhome.com/file/2023/6/100926_0s.webp)
Python使用future处理并发问题方案详解
2022-12-10 18:16:53
JavaScript Base64编码和解码,实现URL参数传递。
2024-04-22 22:45:32
AXObject解决IE需要激活 ActiveX 控件方法
2007-11-08 12:16:00
python实现windows下文件备份脚本
2021-05-06 06:32:41
Python中除法使用的注意事项
2021-11-07 07:18:17
Python之Web框架Django项目搭建全过程
2022-03-21 03:06:08
![](https://img.aspxhome.com/file/2023/3/93853_0s.png)
pandas中DataFrame修改index、columns名的方法示例
2022-02-14 15:42:37