为什么要使用document.write? [英] Why use document.write?

查看:62
本文介绍了为什么要使用document.write?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么广告仍然使用document.write方法将添加项插入页面

I was wondering why ad's still use the document.write approach to inserting the add into the page

<script language="javascript" type="text/javascript">
    document.write("<script type='text/javascript' src='http://addomain/someadd.js'><\/sc" + "ript>");
</script>

为什么我不能只放

<script type='text/javascript' src='http://addomain/someadd.js'></script>

代替广告?

推荐答案

传统的脚本标签将在页面加载和执行时阻止页面.加载了document.write的脚本将异步工作.因此,您会在广告或分析中看到此内容,因为此类脚本不会直接影响页面内容.

A traditional script tag will block the page while it is loading and executing. A script loaded with document.write will work asynchronously. That's why you see this on ads or analytics, as such scripts don't influence the page content directly.

这篇关于为什么要使用document.write?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆