顯示具有 JAVASCRIT 標籤的文章。 顯示所有文章
顯示具有 JAVASCRIT 標籤的文章。 顯示所有文章

2011年1月28日 星期五

[jQuery] lightbox 彈出時造成頁面上的 Flash 消失

最近工做上需求使用了 lightbox2 燈箱效果(jQuery 版,jquery-lightbox-0.5.js),而當 lightbox 彈出後,頁面上的 Flash 項目卻都消失了。看了一下 jquery-lightbox-0.5.js 的原始碼,原來是為了避免 Flash 顯示於最上層,也就是跑到 overlay 黑底的上面,而加上蹦現時將 embed、object 與 select 元素隱藏的語法。

其實可以利用 Flash 的 wmode 屬性避免這種現象,同時也可在燈箱效果出現時顯示 Flash(當然,是在 overlay 黑底下方)。

1、首先打開 jquery-lightbox-0.5.js,在約 68 行處找到:
程序代碼 程序代碼
1 $('embed, object, select').css({ 'visibility' : 'hidden' });

將該行刪除或加上註解,使之失效。

2、接著至原 HTML 頁面,將 Flash 項目加上 wmode 屬性,屬性值 transparent。
此部份自行搜尋關於 Flash 與 DIV 圖層先後順序的問題,在此不再贅述。

如此應該就能在 lightbox 效果出現時,保持 Flash 項目了。

文章提供: BAYSTARS DESIGN網頁設計公司

2010年10月18日 星期一

如何獲取當前 select 元素的值

  • 如果 select 元素下的所有 option 元素均沒有指定 selected 屬性,會默認選中第一個。

  • 可以通過 select.selectedIndex 獲取到選中的 option 元素的索引。

  • 可以通過 select.options

  • [select.selectedIndex] 獲取到選中的 option 元素。
  • option 元素 text3,可以通過 option.value 獲得 option 元素的 value 屬性值,即 value3;可以通過 option.text 獲得 option 元素內的文本,即 text3。

  • 如果 option 元素沒有定義 value 屬性,則 IE 中 option.value 無法獲得,但 Safari、Opera、FireFox 依舊可以通過 option.value 獲得,值同於 option.text 。

  • 可以通過 option.attributes.value && option.attributes.value.specified 來判斷 option 元素是否定義了 value 屬性。


  • 故,獲得當前 select 元素值的腳本如下:

    程序代碼 程序代碼
    var getSelectValue = funtion(select) {
        var idx = select.selectedIndex,
            option,
            value;
        if (idx > -1) {
            option = select.options[idx];
            value = option.attributes.value;
            return (value && value.specified) ? option.value : option.text);
       }
        return null;
    }

    原文:需要點這裡...

    文章提供: BAYSTARS DESIGN網頁設計公司