?? day3_9.html
字號:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312-80">
<style type="text/css">
<!--
a:link { color: blue; text-decoration: none}
a:visited { color: purple; text-decoration: none}
a:hover { color: #CC0033; text-decoration: underline}
-->
</style>
<title>JavaScript高級教程</title>
</head>
<body topmargin="1" leftmargin="2">
<table border="0" width="591" cellspacing="0">
<tr>
<td bgcolor="#ffff99" width="451">JavaScript高級教程 - 第三課</td>
</tr>
<tr>
<td bgcolor="#FF6600" width="451"><a href="mailto:thau@wired.com">Thau</a></td>
</tr>
</table>
<div align="left">
<table border="0" width="630" cellspacing="0">
<tr>
<td width="458" valign="top" align="left" rowspan="2"><small><small><br>
</small></small><strong>第九頁:<font size="3" face="宋體">對象和方法的識別</font></strong>
<p><font size="3"><font face="宋體">最佳的方法是你先確定某一段代碼具備什么功能,然后搞清楚<br>
瀏覽器具備什么功能。 </font></font></p>
<font size="3">
<p><font face="宋體">例如,我們知道有些瀏覽器支持圖片替換,有些則不行。好在<br>
可以檢測瀏覽器是否具備這種功能:只需檢測瀏覽器是否具<br>
有<tt>document.images對象即可:</tt> </font></p>
<blockquote>
<pre><font face="宋體">if (document.images)
{
do lots of image swap stuff
}
</font></pre>
</blockquote>
<p><font face="宋體">這樣圖片替換的代碼就只會在支持圖片替換的瀏覽器中才執行。 </font></p>
<p><font face="宋體">這種技巧還可以用于方法和函數。不是所有的;瀏覽器都有各<br>
種方法。例如,在Netscape 4中,你可以用<tt>window.moveTo()</tt>方<br>
法將窗口在屏幕中移動,如果你想在調用該方法之前先檢測瀏<br>
覽器是否具有這種方法,則: </font></p>
<blockquote>
<pre><font face="宋體">if (window.moveTo)
{
make that window fly
}
</font></pre>
</blockquote>
</font>
<p><font size="3"><font face="宋體">確保瀏覽器支持某項功能后再調用該功能可以避免很多無謂的<br>
腳本錯誤。使用瀏覽器功能測試的方法而不是瀏覽器類型測試<br>
的方法可以使你的網頁內容同各種平臺上各種類型各種版本的<br>
瀏覽器都保持同步。<a href="day3_10.html">>></a></font></font></p>
<p><font face="宋體" size="3" color="#000000"><strong>JavaScript高級教程</strong></font><font color="#FF0000" face="宋體" size="3"><br>
</font><font face="宋體"><font color="#FF0000">第一頁</font> <a href="day3_9.html">Javascript高級教程
- 第三課</a><br>
<font size="3"><font color="#FF0000">第二頁</font> <a href="day3_2.html">如何給事件定時</a><br>
<font color="#FF0000">第三頁</font> <a href="day3_3.html">定時循環的概念</a><br>
<font color="#FF0000">第四頁</font> <a href="day3_4.html">定時循環的做法</a><br>
<font color="#FF0000">第五頁</font> <a href="day3_5.html">一個Javascript編寫的時鐘</a><br>
<font color="#FF0000">第六頁</font> <a href="day3_6.html">給定時器加入變量</a><br>
<font color="#FF0000">第七頁</font> <a href="day3_7.html">識別用戶的瀏覽器</a><br>
<font color="#FF0000">第八頁</font> <a href="day3_8.html">如何識別用戶的瀏覽器</a><br>
<font color="#FF0000">第九頁</font> 對象和方法的識別<br>
<font color="#FF0000">第十頁</font> <a href="day3_10.html">History對象</a></font></font></p>
<p>[<a href="day1_1.html">第1課</a>][<a href="day2_1.html">第2課</a>][第3課]<font size="3">[<a href="day4_1.html">第4課</a>][<a href="day5_1.html">第5課</a>]</font></p>
<hr align="left">
<!--webbot bot="Include" U-Include="../../copyright.html" TAG="BODY" startspan -->
<p><font face="verdana, arial, geneva, sans-serif" size="2"><a href="http://phtshop.yeah.net" target="_top">本文根據
網猴 相關文章改編,版權歸原作者所有。</a> </font><font color="#000000"><span class="smallfont"></span></font></p>
<!--webbot bot="Include" endspan i-checksum="15926" --> </td>
</tr>
<tr> </tr>
</table>
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -