patw 的筆記、生活、隨筆
JavaScript
[Facebook] 取得粉絲專頁資訊與最新一筆主題的方法 (PHP/jQuery/ASP.NET(C#))
三月 15th
想要取得粉絲專頁(粉絲團頁面)的公開資訊,以及該粉絲團最新一筆主題該怎麼做呢?
這邊分成三種版本來講:PHP、jQuery 與 C#.NET。
※由於粉絲專頁幾乎是公開資訊,從 Graph API 就可取得。因此其實也可以不用做 app,直接就可以透過 Graph API 撈取。這邊只有 PHP 是用老作法。
[jQuery] 使 ASP.NET 的 DropDownList 支援選項分組(optgroup)
三月 2nd
由於 ASP.NET 的 DropDownList 控制項不支援 optgroup 標籤,就無法做選項分組的功能 ..
後來想用 jQuery 實現此一功能,我寫成 plugin 了,可參考一下:
把這段 code 存成 optgroupTrans.js:
$.fn.optgroupTrans = function() {
var items = $(this);
var groupnames = [];
for (var i = 0; i < items.length; i++) {
if ($(items[i]).attr("optgroup") != null) {
groupnames.push($(items[i]).attr("optgroup"));
}
}
//groupnames = $.unique(groupnames);
groupnames = uniqueArray(groupnames);
for (var i = 0; i < groupnames.length; i++) {
$("option[optgroup='" + groupnames[i] + "']").wrapAll("<optgroup label='" + groupnames[i] + "'>");
}
function uniqueArray(a){
temp = new Array();
for(var i = 0; i < a.length; i ++){
if(!contains(temp, a[i])){
temp.length+=1;
temp[temp.length-1] = a[i];
}
}
return temp;
}
function contains(a, e){
for(j=0;j<a.length;j++)if(a[j]==e)return true;
return false;
}
};
[JavaScript] Shadowbox 燈箱效果於父視窗展示 iframe 頁中的圖片 Gallery
十二月 29th
好,我知道這個標題相當拗口 XD
前幾天寫了篇 [JavaScript] ColorBox 跨越 iframe 顯示完整的黑底(overlay) ,但詢問的網友表示他希望能展示圖片群組,不過ColorBox 的官網,關於 Opening ColorBox in the parent of an iframed document 的這段,最後提到:
Note that grouping will not work with this format since the parent document can not access the content of the iframe to see if any of those elements share a rel attribute value.
也就是用這種方法的話,是無法取得 iframe 中元素的 rel 值的,因此也就無法展示圖片群組了。
也許可以修改以達成目的,但目前還沒空細細研究他的 Code .. 於是就偷懶先找其他替代方案囉
經過連來連去的找尋,找到 Shadowbox.js 這套燈箱效果是可以達成在 iframe 的父視窗展示圖片群組的!以下就來看看做法吧。
[AJAX] 跨網域取得/存取資料
十二月 21st
[AS3][JavaScript] Facebook 發佈訊息的方法
十一月 29th
本篇延續 [AS3] Facebook 朋友列表在 Flash 中用捲軸方式呈現 這篇,一樣用 Jozef Chúťka 前輩所寫的 Facebook AS3 Graph API 作法,來發佈訊息到塗鴉牆上。(由於 Connect 時就應用程式就會要求發佈塗鴉牆的權限,因此這種方法就不會跳出任何發佈視窗喔)
此外也附加了一個以 JavaScript 方式發佈塗鴉牆的方法,這個就會跳出常見的發佈訊息小視窗囉。可以依需求搭配使用~
Facebook AS3 Connect 方法在此一樣不提,請自行參考教學連結。
※ 其中要注意的是,發佈時需發佈成 Flash Player 10 版本,否則在 IE 中會無法在 connect 後正確 authorized!會一直跳出 callback.htm 頁面卻無法正確授權。為了這個問題卡很久,需特別注意。
[jQuery] 倒數計時(還有X天X時X分X秒)
十月 19th
jQuery 倒數計時, 需要 jQuery.Timers 這個 plugin.
startDate 可以用 server 的時間輸出, 避免 client 的電腦時間不準。
[JavaScript] 在非 IE 瀏覽器上使用 AC_FL_RunContent 載入 Flash 無法取得物件名稱的解法
九月 20th
使用 Adobe Dreamweaver 插入 Flash SWF 物件時,會自動加上 AC_RunActiveContent.js 這個檔案,並用 AC_FL_RunContent 方法載入 Flash 內容。
我們想在網頁上藉由 JavaScript 傳遞參數給 SWF,這會用到 Flash 物件的 id 值;在 IE 上都很正常,可以正確地抓到 Flash 物件,可在非 IE 瀏覽器(如 Chrome)卻只會吐 undefined。
找到了下面這篇:
http://stackoverflow.com/questions/2229358/why-cant-i-get-javascript-to-talk-to-actionscript



近期迴響