patw 的筆記、生活、隨筆
Posts tagged jQuery
[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 的父視窗展示圖片群組的!以下就來看看做法吧。
[jQuery] lightbox 彈出時造成頁面上的 Flash 消失
六月 10th
某個案子使用了 lightbox2 燈箱效果(jQuery 版,jquery-lightbox-0.5.js),而當 lightbox 彈出後,頁面上的 Flash 項目卻都消失了。看了一下 jquery-lightbox-0.5.js 的原始碼,原來是為了避免 Flash 顯示於最上層,也就是跑到 overlay 黑底的上面,而加上蹦現時將 embed、object 與 select 元素隱藏的語法。
其實可以利用 Flash 的 wmode 屬性避免這種現象,同時也可在燈箱效果出現時顯示 Flash(當然,是在 overlay 黑底下方)。
More >
近期迴響