2009年1月11日

navigator 二頁

一頁 | 二頁 | 三頁
navigator 的特徵
onLine

存有一個布林值,true 表示瀏覽器是上線,false 是離線。

  • 程式用法:

    <script type='text/javascript'>
    document.write( navigator.onLine );
    </script>

  • 執行結果:

    true

  • Safari, Chrome 無此項;IE, Firefox 都有支援。
oscpu

存放作業系統的字串。限 Firefox 使用。

  • 程式用法:

    <script type='text/javascript'>
    document.write( navigator.oscpu );
    </script>

  • 執行結果:

    undefined

platform

存有瀏覽器的平台字串。

  • 程式用法:

    <script type='text/javascript'>
    document.write( navigator.platform );
    </script>

  • 執行結果:

    Linux x86_64

plugins

存放一個陣列,內有瀏覽器安裝的插頭軟體。

  • 程式用法:

    <script type='text/javascript'>
    document.write( navigator.plugins.length +'<br />');
    for( k in navigator.plugins[0] )
      document.write( k +' : '+ navigator.plugins[0][k] +'<br />');
    </script>

  • 執行結果:

    0

  • IE 沒有輸出;Firefox, Safari, Chrome 都有輸出,但是有差異。
product

存有瀏覽器的商品名稱。

  • 程式用法:

    <script type='text/javascript'>
    document.write( navigator.product );
    </script>

  • 執行結果:

    Gecko

  • IE, 無此項;Firefox, Safari, Chrome 都輸出”Gecko”。
productSub

存有瀏覽器的建造編號。

  • 程式用法:

    <script type='text/javascript'>
    document.write( navigator.productSub );
    </script>

  • 執行結果:

    20030107

  • IE, 無此項;Firefox, Safari, Chrome 都支援。
userAgent

存有瀏覽器的用戶執行器字串。

  • 程式用法:

    <script type='text/javascript'>
    document.write( navigator.userAgent );
    </script>

  • 執行結果:

    Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)


©2008-2009 by ant2legs, All Rights Reserved. ant2legs 擁有其製作的文章,圖片與程式的著作權,所有權利保留。