網頁設計公司
您現在的位置:首頁  >  新聞中心
  • 軟體設計
    Software Development
  • 品牌及LOGO設計
    Brand and LOGO Design
  • 網站設計及建制
    Web Design
  • 多媒體動畫制作
    Multimedia Presentations
  • 聯絡我們
    Contact US
  • 新聞中心
    網頁設計公司必讀的文章 ( 290 ) 如何在 IE 中使用 HTML5 元素
    Sjoerd Visscher 發現了一個簡潔的 方法 讓樣式在 IE 中作用到未知的元素上——僅需 JS 創建此未知元素即可:
    document.createElement(elementName)
    同理(對於 IE 來說 HTML5 元素即是未知元素),該方法也可順延到 HTML5 的元素上(詳細見:John Resig 寫的 《HTML5 Shiv》 一文):
    程序代碼 程序代碼
    <html>
    <head>
    <style>section { color: red; }</style>
    <script>document.createElement("section")</script>
    </head>
    <body>
    <section>Hello World!</section>
    </body>
    </html>

    在 IE 中,為了更方便使用 HTML5 元素,我們可以引入這樣的腳本:
    程序代碼 程序代碼
    (function(){
        // from: http://dean.edwards.name/weblog/2007/03/sniff/
        if(!/*@cc_on!@*/0) return;

        var html5 = "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,
    eventsource,figure,footer,hgroup,header,mark,menu,meter,nav,output,
    progress,section,time,video".split(',');
        for(var i = 0, len = html5.length; i < len; i++ )
            document.createElement(html5[i]);
        }
    })();


    詳細具體應用的案例如下:

    《Moving markup towards HTML5》
    《Test new HTML 5 elements》

    Popularity: 5% [?]

    原文:點這裡...

    文章來自 BAYSTARS DESIGN網頁設計公司

    首頁 | 關於我們 | 新闻中心 | 聯絡我們 | 加入最愛
    Bay Stars Design 網頁設計公司 Copyright © 2005-2008 Bay Stars Design Web Design Company All risghts reserved.