JS嵌套有什么语法错误?在线等!
菜鸟自学做网站。
原来网页有段代码AAAA,调用GOOGLE ADSENSE的JS代码。
现在需要把代码AAAA写成JS,那么就出现了JS里面调用GOOGLE ADSENSE的JS代码的问题。
因此显示不正确。
显示结果:
请高手们指正!
原来AAA代码如下:
<TR>
<TD height=60 width=168 vAlign=bottom> 123 </TD>
<TD height=60 width=510 vAlign=bottom align=center>
<script type= "text/javascript "> <!--
google_ad_client = "pub-9419450997426427 ";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as ";
google_ad_type = "image ";
google_ad_channel = " ";
//--> </script>
<script type= "text/javascript "
src= "http://pagead2.googlesyndication.com/pagead/show_ads.js ">
</script> </TD>
<TD height=60 width=100 vAlign=bottom align=right> 456 </TD>
</TR>
AAAA转换后的JS代码如下:
document.writeln( " <TR> ");
document.writeln( " <TD height=60 width=168 vAlign=bottom> 123 <\/TD> ");
document.writeln( " <TD height=60 width=508 vAlign=bottom align=center> ");
document.writeln( " <script type=\ "text\/javascript\ "> <!-- ");
document.writeln( "google_ad_client = \ "pub-9419450997426427\ "; ");
document.writeln( "google_ad_width = 468; ");
document.writeln( "google_ad_height = 60; ");
document.writeln( "google_ad_format = \ "468x60_as\ "; ");
document.writeln( "google_ad_type = \ "image\ "; ");
document.writeln( "google_ad_channel = \ "\ "; ");
document.writeln( "\/\/--> <\/script> ");
document.writeln( " <script type=\ "text\/javascript\ " ");
document.writeln( " src=\ "http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\ "> ");
document.writeln( " <\/script> <\/TD> ");
document.writeln( " <TD height=60 width=100 vAlign=bottom align=right> 456 <\/TD> <\/TR> ");
------解决方案--------------------需要这么做么?看不到这样做的意义所在。
------解决方案--------------------注意单双引号
document.writeln( 'src=\ "http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\ "> ')
document.writeln( ' <\/script> <\/TD> ');
document.writeln( ' <TD height=60 width=100 vAlign=bottom align=right> 456 <\/TD> <\/TR> ');
------解决方案--------------------把最后一句单独写在一个 <script> </script> 里