我想添加一个javascript google广告,但是我无法将javascript插入到使用jquery的div中。我尝试用这个测试来模拟我的问题,它使用了我在stackoverflow上发现的一些建议,但它不起作用。用jquery将html添加到html页面
我想<script type='text/javascript'>document.write('hello world');</script>
被插入到div中,并且在标签_1和标签__2之间显示“hello world”。
下面是代码:
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var str="<script type='text/javascript'>document.write('hello world');";
str+="<";
str+="/script>";
$('#insert_here').append(str);
});
</script>
</head>
<body>
tag_1<br/>
<div id="insert_here">
</div>
tag_2<br/>
</body>
</html>
坦克为您解答,
卢卡斯
Adsense是非常严格的,显示:没有可能得到即使这是无害的,你也禁止了。我不会尝试Adsense广告的任何聪明之处。 – 2013-10-13 07:21:30
好点 - 不会破坏解决方案 - 只是删除显示:无 - 您仍然可以使用此解决方案加载广告并将它们移动到所需的位置。 – 2013-10-15 08:25:38