博客园中每篇文章的评论窗口最下面就带了一个Google的广告,当然我这个博客也不例外。不过这些广告我看着就不爽,于是就想办法把该死的广告去掉。使用Mathon2打开博客园中的任何一篇文章,选定Google广告和周围区域,右键“查看选定区域代码”就可以看到原来是Google的JS文件在我的页面中生成了一个Iframe,具体代码为:
<
SCRIPT type
=
text
/
javascript
><!--
google_ad_client = " pub-4210569241504288 " ;
google_ad_width = 468 ;
google_ad_height = 60 ;
google_ad_format = " 468x60_as " ;
google_ad_type = " text " ;
google_ad_channel = "" ;
google_color_link = " 6699CC " ;
// --></SCRIPT>
< SCRIPT src = " http://pagead2.googlesyndication.com/pagead/show_ads.js "
type = text / javascript >
</ SCRIPT >
< IFRAME name = google_ads_frame marginWidth = 0 marginHeight = 0
src = " http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4210569241504288&dt=1178792060846&lmt=1178792060&format=468x60_as&output=html&url=http%3A%2F%2Fwww.cnblogs.com%2Fmsdpe%2Farchive%2F2007%2F05%2F10%2F741928.html&color_link=6699CC&ad_type=text&ref=http%3A%2F%2Fwww.cnblogs.com%2F&cc=134&flash=9&u_h=1024&u_w=1280&u_ah=994&u_aw=1280&u_cd=32&u_tz=480&u_his=1&u_java=true "
frameBorder = 0 width = 468 scrolling = no height = 60
allowTransparency ></ IFRAME >
既然代码看到了,那么解决办法也比较简单,在博客园后台管理中-选项-配置:通过CSS定制页面中添加一个CSS:
google_ad_client = " pub-4210569241504288 " ;
google_ad_width = 468 ;
google_ad_height = 60 ;
google_ad_format = " 468x60_as " ;
google_ad_type = " text " ;
google_ad_channel = "" ;
google_color_link = " 6699CC " ;
// --></SCRIPT>
< SCRIPT src = " http://pagead2.googlesyndication.com/pagead/show_ads.js "
type = text / javascript >
</ SCRIPT >
< IFRAME name = google_ads_frame marginWidth = 0 marginHeight = 0
src = " http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4210569241504288&dt=1178792060846&lmt=1178792060&format=468x60_as&output=html&url=http%3A%2F%2Fwww.cnblogs.com%2Fmsdpe%2Farchive%2F2007%2F05%2F10%2F741928.html&color_link=6699CC&ad_type=text&ref=http%3A%2F%2Fwww.cnblogs.com%2F&cc=134&flash=9&u_h=1024&u_w=1280&u_ah=994&u_aw=1280&u_cd=32&u_tz=480&u_his=1&u_java=true "
frameBorder = 0 width = 468 scrolling = no height = 60
allowTransparency ></ IFRAME >
iframe
{
display : none ;
}
这样就可以把Google的广告屏蔽了。
{
display : none ;
}
但是这里有一个问题就是这样做是把所有的Iframe都不显示了,如果页面中有其他的Iframe需要显示怎么办?但是CSS好像不允许通过name=google_ads_frame来定义,说来的确奇怪,为什么CSS中有class,有id就是没有name 拉?这点我还不明白。估计只有写JS来实现了。
本文转自深蓝居博客园博客,原文链接:http://www.cnblogs.com/studyzy/archive/2007/05/10/741949.html,如需转载请自行联系原作者