Ad标记并尝试使用append/appendTo而不是document.write-不起作用
Ad tag and trying to use append / appendTo instead of document.write - not working
我做了很多搜索,但找不到答案。这是代码
<div id="uniquediv"></div>
<script language="JavaScript">
(function($){
var srcitem = 'http://someURL_to_an_AD_tag';
$('<script/>', {
type: 'text/javascript',
src: srcitem
}).appendTo("#uniquediv");
})(jQuery);
</script>
无论我做什么(尝试了很多不同的东西),js代码都不在"uniqueid"div中。我需要它在div中,因为div有填充,我需要保留它,因为我包含的js是一个广告,我需要在它周围有填充。
(我完全收回了以前的答案)。
在jQuery中执行$("<script>")
时,会立即下载并执行脚本。在这种情况下,.appendTo可能没有任何效果,尤其是如果广告正在执行document.write.
document.write可能是这种情况下的方法。我不认为真的有任何负面影响。如果你的广告src是静态的,你甚至可能想完全跳过javascript,只在你的div中做一个标记。
相关文章:
- 正在寻找比$(document).ready慢的$(window).load的替代方案
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 在Jquery detachment()和appendTo()之后定位元素
- 如何用更合适的内容替换document.write
- document.styleSheets不返回任何内容
- jQuery document.ready not working
- $(document).height()在刷新时随机化值(Safari 5.1.10)
- reactjs this.refs vs document.getElementById
- 如何通过adf中的document.getElementById获取inputText字段值
- window.opener.document在ie中不起作用
- contentWindow.document.body is null
- document.applet.method在Mounatin Lion上抛出safari 6+JDK7异常
- document.getElementById(“st”).click();不起作用
- $(document).height和$(window).heaght都返回相同的值-使用的是正确的doctype
- jQuery document.ready停止代码
- document.getElementById并使用id名称
- 使用jQuery 1.8.1准备好多个$(document).是否有任何开销
- document.getElementById在js中不起作用
- document.getElementById.style.backgroundImage not working
- Ad标记并尝试使用append/appendTo而不是document.write-不起作用