Re: [問題] 在網誌上運用Flickr照片...

看板Flickr作者 (Vista 中文版運行中)時間17年前 (2007/01/26 11:56), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
※ 引述《ericapricorn (為彥)》之銘言: : 標題: Re: [問題] 在網誌上運用Flickr照片... : 時間: Thu Jan 25 23:19:12 2007 : -- : ※ 發信站: 批踢踢實業坊(ptt.cc) : ◆ From: 61.62.145.142 : 推 emmey:我設定成功了喲!謝謝! (請問這類語法是要找哪些書才有啊) 01/25 23:36 : 推 lynnlin:不用買 網路一堆 http://chinese.allproducts.com.tw/html 01/25 23:57 : → lynnlin:這個還滿淺顯易懂的 ^o^ 希望有幫到你 :-) 01/25 23:58 : 推 sandor:有辦法由CSS設定嗎? 畢竟圖一多...恩~我承認我是懶人 XD 01/26 00:43 : 推 NintendoGC:自己寫個 script 去掃頁面, 看連結是不是連到 flickr 01/26 11:39 : → NintendoGC:是的話, 動態加入 target 屬性 01/26 11:40 只供參考, 我沒實際跑... 不能跑的, 請自己 debug 一下... 當然, 要加到 onload 事件去, 怎麼加就看個人了... 另外, 要寫得更嚴謹一點的, 除了判斷 link 位址, 還要再去抓 <a> 的子元件是不是 <img>, 是的話再動態加 target... 不然我這個寫法, 所有連到該位址的連結, 管它是不是圖片都會開在新視窗或分頁... function initAll() { if (!document.getElementsByTagName){ return; } var anchors = document.getElementsByTagName('a'); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; var hrefAttribute = String(anchor.getAttribute('href')); if (hrefAttribute && hrefAttribute.toLowerCase().match('http://www.flickr.com/photos/')) { var targetAttribute = document.createAttribute("target"); targetAttribute.nodeValue = "_blank"; anchor.setAttributeNode(targetAttribute); } } } 另外, 不建議強制開在新視窗或分頁的作法, 因為, 要不要開在新視窗或新分頁, 應該讓 "瀏覽者" 有權決定... -- BLOG - http://www.goston.net/ Album - http://www.flickr.com/photos/goston/sets/ Photo Blogging - http://photo-collect.blogspot.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.124.214.30 ※ 編輯: NintendoGC 來自: 59.124.214.30 (01/26 12:09)
文章代碼(AID): #15kNlJiK (Flickr)
討論串 (同標題文章)
文章代碼(AID): #15kNlJiK (Flickr)