Creative Commons License
本 著作 係採用 創用 CC 姓名標示-相同方式分享 2.5 台灣 授權條款授權.
    原構想來自於 Nelson 的遊樂場自動加入Google Adsense的文章,原本是把它單純的改放BloggerADS的推廣連結,但總覺得只有一個模式真的很醜。後來看到Nelson也把廣告作成輪播的方式,跟我當初想到可以利用JavaScript隨機播放的語法,來作簡單的輪撥功能的這個想法不謀而合。但是同樣的<script><script>....</script></script>這個不符合規範的問題還是沒有解決啊(雖然說是可以成功的呈現啦)。希望有看到這篇的先進能夠交流一下怎麼改會比較好。我真的笨掉了,看來這個辦法只能用於圖片連結啊,持續改寫......

    為了尊重原作者,詳細的教學還是請連回 Nelson 的 頁面感謝原作者的程式提供,因為是直接改寫自Nelson的版本,所以理論上原本Pixnet / 無名小站(付費會員) / 天空部落 / 樂多部落 / 新浪部落可以使用,本JavaScript應該也可以使用。實際成果可以隨便逛我的部落格就可以看到了喔。

使用步驟:

1. 請先到Nelson的部落格,詳細閱讀如何插入Google Adsense請務必要看!!
2. 請複製以下程式碼,打開記事本或是任何可以編輯文字的軟體,貼上它。

/*
 * 作者: backtrue (http://blog.pixnet.net/backtrue)
 * 說明: 讓 Pixnet 的文章隨機出現使用者想要呈現的廣告
 * 備註: 原始程式碼來自 http://blog.xuite.net/emisjerry/tech/11088489,
 *           Nelson將它改成適合 Pixnet 的版本。http://blog.pixnet.net/Nelson/post/3967606
 *           我個人再把他稍微再改寫了一下,變成可以隨機播放任何的廣告。
 * 版本: v1.0,2007/12/04
 * 適用: 使用Nelson自動加入廣告JS的部落客。
 * 授權: 自由使用及修改,記得到我的版上留個言給我鼓勵吧。
 *           http://blog.pixnet.net/backtrue
 * 難易度:中,需略懂html語法
 * 修改時間:5分鐘
 */
<script language="JavaScript">
var linkno = 7;/*請依自己想放廣告的數量作更改,這裡是設成7個廣告聯播*/
var date = new Date();
var rd = date.getMinutes();
var ra = rd % linkno;
var re = ++ra;
var mo=0
frame="_blank"

if (re < 1) re=++re

if (re == 1) {
re = "http://author.bloggerads.net/01_join_read.aspx?refid=10034&amp;id=20070619000003";/*請自行解析廣告連結*/
mo = "http://author.bloggerads.net/referrals/A_180_60.gif";/*請自行解析廣告圖片*/
}

if (re == 2) {
re = "http://author.bloggerads.net/01_join_read.aspx?refid=10034&amp;id=20070619000003";//連結目標
mo = "http://author.bloggerads.net/referrals/B_180_60.gif";//圖片位置
}

if (re == 3) {
re = "http://author.bloggerads.net/01_join_read.aspx?refid=10034&amp;id=20070619000003";//連結目標
mo = "http://author.bloggerads.net/referrals/C_180_60.gif";//圖片位置
}

if (re == 4) {
re = "http://author.bloggerads.net/01_join_read.aspx?refid=10034&amp;id=20070619000003";//連結目標
mo = "http://author.bloggerads.net/referrals/D_180_60.gif";//圖片位置
}

if (re == 5) {
re = "http://author.bloggerads.net/01_join_read.aspx?refid=10034&amp;id=20070619000003";//連結目標
mo = "http://author.bloggerads.net/referrals/E_180_60.gif";//圖片位置
}

if (re == 6) {
re = "http://author.bloggerads.net/01_join_read.aspx?refid=10034&amp;id=20070619000003";//連結目標
mo = "http://author.bloggerads.net/referrals/F_180_60.gif";//圖片位置
}

if (re == 7) {
re = "http://author.bloggerads.net/01_join_read.aspx?refid=10034&amp;id=20070619000003";//連結目標
mo = "http://author.bloggerads.net/referrals/G_180_60.gif";//圖片位置
}

/*if (re == N) {
re = "";//連結目標
mo = "";//圖片位置
}
*/

var link="<a href="+re+"><img" _fcksavedurl=""+re+"><img"" src="+mo+"></a>";
document.write(link);

</script>

 
請注意紅色的部份,待會我們要修改的就是紅色的部份,草綠色部份是留給大家再加其他的廣告時方便使用的。

或是直接下載:http://backtrue.googlepages.com/random_ad_js.js

3. 登入你想要插入廣告的廣告商頁面(這裡以BloggerADS為例),為求美觀(?)所以我喜歡用圖片連結。當然你也可以使用文字連結啦,不過不試用本篇的JS就是了。本文目前只支援推廣連結,我會努力try的

4. 找到你想加入輪播的廣告圖片及連結。小黑好心的告訴你,圖片請複製< i m g  s r c="這裡面的文字">,連結請複製< a  h e r f = "這裡面的文字 ">,取代原本JavaScript紅字的位置。記得修改廣告的數量唷。

5. 最後把整段文字複製回原本Nelson的程式兩個『br』之間。

6. 打開你的部落格,就可以看到成果啦!

backtrue 發表在 痞客邦 PIXNET 留言(9) 人氣()


留言列表 (9)

發表留言
  • Tejada
  • You can also put inside gold or add-ons bracelets or bead earrings. Believe it or not than Hollywood hottie Megan Fox encourages Emporio Armani. Infant Knitwear has been considered extremely suitable for young babies and toddlers. Another look featured longer length black pants. http://www.2011zuoxuan.info/News/user/profile/aubreycul/
  • Mccune
  • The golden age with haute couture back again to the 50's. In fact, in 2005, the fashion house celebrated all by re-releasing the standard just as food. She might also been almost unknown then, but she experienced the press joining up for pictures! Athletic luxury brands is a must for true fashionistas. http://nalanda.org.br/ead/user/view.php?id=93660&course=1
  • Mcrae
  • It's ideal for that woman who could be most comfortable inside of cashmere and nuggets. This basically only makes your focus look even better together. You at least need a horrible case that is built to resist smashing, becoming or breaking. Use ordinary leather or amazing hand made pendants. http://sacstateasce.org/tiki-index.php?page=UserPageshirleycummings
  • Mauldin
  • Hi, buddies, here I'm to share had been experiences in mascara. African and white seemed to be a dominant theme, as well as loose ethereal tops and skirts. If you need the karen millen The site bag you will have the a few.55 bag. Right now, Beyonce and India's particular Kareena Kapoor Khan are also identify ambassadors. http://www.shared-care.com/author/Corinne08
  • Maple
  • Hey there! Someone in my Facebook group shared this website with us so I came to take a look. I'm definitely loving the information. I'm bookmarking and will be tweeting this to my followers! Outstanding blog and outstanding design and style.
  • Chilton
  • Howdy would you mind stating which blog platform you're using? I'm going to start my own blog in the near future but I'm having a tough time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I'm looking for something unique. P.S My apologies for being off-topic but I had to ask!
  • Mcwilliams
  • Incredible points. Sound arguments. Keep up the amazing spirit.
  • Farias
  • Wow that was unusual. I just wrote an really long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Anyways, just wanted to say great blog!