gpt4 book ai didi

javascript - 使用 document.write() 插入脚本标签有什么好处(用于显示单个广告)?

转载 作者:行者123 更新时间:2023-11-30 09:47:58 24 4
gpt4 key购买 nike

显然,很多广告人员使用 document.write() 来将额外的脚本插入到页面中。

例如:

var url = 'http://ads.com/buyme?rand=' + Math.random()
document.write('<script src="'+ url +'"></scr'+'ipt>')

使用这些技术有什么好处?

为什么不写 <script src="'http://ads.com/buymev?rand=123"></script>像往常一样进入 HTML?或者使用 document.createElement('script')?

当我想向某人展示广告时,使用 document.write() 有什么特别的好处?

最佳答案

document.write 可以将任意、甚至部分、不完整和格式错误的 HTML 附加到文档中。它非常快,因为浏览器不必修改现有的 DOM 结构。

一个很棒的链接 http://javascript.info/tutorial/document-write

关于javascript - 使用 document.write() 插入脚本标签有什么好处(用于显示单个广告)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37990424/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com