喜悦国际村 » XML/HTML/CSS/Js » 为何DIV嵌套在JS代码后不能实现广告与文章混排

页: [1]
lcsnow2008-5-18 12:37 PM
为何DIV嵌套在JS代码后不能实现广告与文章混排

在文章中调入a.js文件,调用代码为
<script type="text/javascript" src="http://www.51skill.cn/jsforad/articletop.js"></script> 后面加文章内容代码
a.JS文件代码如下:
[code]
document.writeln("<div style=\"float:left;width:336px;height:280px;\">");
document.writeln("<script type=\"text\/javascript\"><!--");
document.writeln("google_ad_client = \"pub-50262898418895229\";");
document.writeln("\/* 336x280, 创建于 08-5-13 *\/");
document.writeln("google_ad_slot = \"1784659134\";");
document.writeln("google_ad_width = 336;");
document.writeln("google_ad_height = 280;");
document.writeln("\/\/-->");
document.writeln("<\/script>");
document.writeln("<script type=\"text\/javascript\"");
document.writeln("src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">");
document.writeln("<\/script>");
document.writeln("<\/div>");
[/code]
这样不能实现文字与广告混排的形式,而且上面还留一大部分空白,不知到为何?
如修改成下列形式就可以:

<div style="float:left;width:336px;height:280px;">
<script type="text/javascript" src="http://www.51skill.cn/jsforad/articletop.js"></script>
</div>

Js代码如下:

[code]
document.writeln("<script type=\"text\/javascript\"><!--");
document.writeln("google_ad_client = \"pub-50262898418895229\";");
document.writeln("\/* 336x280, 创建于 08-5-13 *\/");
document.writeln("google_ad_slot = \"1784659134\";");
document.writeln("google_ad_width = 336;");
document.writeln("google_ad_height = 280;");
document.writeln("\/\/-->");
document.writeln("<\/script>");
document.writeln("<script type=\"text\/javascript\"");
document.writeln("src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">");
document.writeln("<\/script>");
[/code]

请问是什么原因,改如何修改才能实现,谢谢!


查看完整版本: 为何DIV嵌套在JS代码后不能实现广告与文章混排


Powered by Discuz! Archiver 6.1.0  © 2001-2006 Comsenz Inc.
Processed in 0.044167 second(s), 2 queries