这是我不小心遇到的呵!昨天在同类(免费资源)站看到我朋友载入的广告代码
gethtm(‘/adfile/chongzhi.htm’,’k_ad_chongzhi’); |
我就比较好奇了,我自己都是用 载入广告 有时候到载入这段JS 都会卡主一下 于是我就想 改成 他那样的 于是就去网络搜索.搜索了半天 就只搜索到篇 也是跟我朋友差不多显示的 载入flash代码 G_flash(‘http://www.freejia.com/plus/free/xxx.swf’,468×60,0); 是用一个JS文件引用的 但是它宽度 高度 都固定住了 以后改广告也要考虑这个问题.于是我自己就改了下代码 废话不多说 告诉大家怎么弄吧!
首先创建一个JS文件内容是:
document.writeln(" "); document.writeln(" "); document.writeln(" function G_banner(url,transparent) { "); document.writeln(" \/\/ Clear active line of the flashs for IE "); document.writeln(" var param_t=\”; "); document.writeln(" if (transparent!=0) { "); document.writeln(" param_t=\’wmode=&;transparent&;’; "); document.writeln(" } "); document.writeln("document.write(\'’);") document.writeln(" } "); document.writeln("") |
然后在HTML页面插入
G_banner(‘http://www.freejia.com/plus/free/banner.html’,0); 顶部插入 |
就行了!宽度高度在JS里控制 方便我们 修改
如何创建多个广告位?在JS里加:
document.writeln(" "); document.writeln(" "); |
看到了吧 两个 引用的 G_banner G_tl
那就用
G_banner(‘http://www.freejia.com/plus/free/banner.html’,0); G_tl(‘http://www.freejia.com/plus/free/banner.html’,0); |
用这样的方法 可以免去JS解析里面代码的时间 直接打开html 也不需要一个一个JS修改 我们只用一个JS就可以控制全站广告
因为这个是一下子打开全部广告页面 会感觉有点慢 那我们在html里就加入网络流传的
广告载入中… 广告代码 ad_01.innerHTML=span_ad_01.innerHTML;span_ad_01.innerHTML=""; |
速度会比原来快了些 好了 到此结束! 我小心 第一次写文章 不好别骂我!
著下自己站 免费家 http://www.freejia.com 大家支持下哈!
转载请注明:SEO爱站网 » 案例分析网:优化网页广告代码以及速度