无闪烁更新网页内容JS实现
时间:2024-05-09 10:37:18
todo list
无闪烁更新网页的课题比较大。
加载的html字符串(通过ajax获取的),如果还需要运行代码,那么肯定有问题。
希望用一个不显示的iframe来承载这个对象。这有点dirty work的感觉。
最终解决方案是
var str2DOMElement = function(html) {
var frame = document.createElement('iframe');
frame.style.display = 'none';
document.body.appendChild(frame);
frame.contentDocument.open();
frame.contentDocument.write(html);
frame.contentDocument.close();
var el = frame.contentDocument.body.firstChild;
document.body.removeChild(frame);
return el;
}
var markup = '<div><p>text here</p></div>';
var el = str2DOMElement(markup);
标签:无闪烁,更新网页内容
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
js substr支持中文截取函数代码(中文是双字节)
2024-04-10 10:44:58
python使用response.read()接收json数据的实例
2021-09-16 08:08:01
如何使用pandas读取txt文件中指定的列(有无标题)
2022-04-25 15:30:18
![](https://img.aspxhome.com/file/2023/3/87733_0s.jpg)
pyhthon绘制超炫酷的心形线星形线摆线
2021-01-15 14:02:30
![](https://img.aspxhome.com/file/2023/5/109455_0s.gif)
sqlserver找回企业管理器的方法
2024-01-27 08:41:54
PHP递归删除目录几个代码实例
2024-05-11 09:24:55
利用jupyter网页版本进行python函数查询方式
2022-05-23 17:27:12
![](https://img.aspxhome.com/file/2023/8/125178_0s.jpg)
Django中提供的6种缓存方式详解
2023-03-24 14:55:49
selenium使用chrome浏览器测试(附chromedriver与chrome的对应关系表)
2022-08-16 16:42:00
![](https://img.aspxhome.com/file/2023/0/98930_0s.png)
Golang接口型函数使用小结
2024-05-08 10:14:53
Python读取xlsx文件报错:xlrd.biffh.XLRDError: Excel xlsx file;not supported问题解决
2021-02-02 16:08:59
![](https://img.aspxhome.com/file/2023/2/72192_0s.png)
ThinkPHP使用smarty模板引擎的方法
2023-11-14 11:37:19
python 找出list中最大或者最小几个数的索引方法
2022-08-12 13:23:11
Oracle与SQL Server数据库镜像对比
2009-03-25 14:27:00
mysql中explain用法详解
2024-01-13 16:28:25
教你快速掌握SQL语言中游标的使用技巧
2009-01-08 16:24:00
ASP不允许同一个用户同时登陆两次
2008-06-03 13:45:00
Django项目连接MongoDB的三种方法
2022-05-27 05:23:43
javascript ajax的5种状态介绍
2024-04-30 10:15:43
一个NumericStepper组件
2010-01-22 15:46:00
![](https://img.aspxhome.com/file/UploadPic/20101/22/num22-95s.png)