欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript hasFocus使用實(shí)例

 更新時(shí)間:2010年06月29日 00:12:19   作者:  
hasFocus是document的特有方法.用來(lái)判斷當(dāng)前網(wǎng)頁(yè)是否獲得焦點(diǎn).
如果網(wǎng)頁(yè)處于焦點(diǎn)狀態(tài)返回true,否則返回fasle
什么是焦點(diǎn)?焦點(diǎn)是指用戶是否活動(dòng)在該頁(yè)面.確切的說(shuō)鼠標(biāo)是否在該網(wǎng)頁(yè)內(nèi)活動(dòng).或者說(shuō)該網(wǎng)頁(yè)中的內(nèi)容是否有被選中的,或者光標(biāo)存在于該頁(yè)的某個(gè)元素內(nèi).如果具備其中一個(gè)條件那么該頁(yè)就處于焦點(diǎn)狀態(tài).注意hasFocus方法只針對(duì)網(wǎng)頁(yè)不針對(duì)瀏覽器.下面的實(shí)例中.你用鼠標(biāo)點(diǎn)擊網(wǎng)頁(yè)時(shí)候.該網(wǎng)頁(yè)處于焦點(diǎn)狀態(tài).你用鼠標(biāo)點(diǎn)擊瀏覽器的地址欄以后.該網(wǎng)頁(yè)失去焦點(diǎn)并顯示false. 再次提醒hasFocus方法只能運(yùn)行在document對(duì)像.請(qǐng)看下面實(shí)例
復(fù)制代碼 代碼如下:

<html>
<head>
<title>Dom:hasFocus方法實(shí)例</title>
</head>
<body onfocus="getFocus()" onblur="Empty_Focus()">
<h2>請(qǐng)點(diǎn)擊網(wǎng)頁(yè)區(qū)域.表明該網(wǎng)頁(yè)獲得焦點(diǎn),顯示為true.點(diǎn)擊瀏覽器地址欄.該網(wǎng)頁(yè)失去焦點(diǎn)顯示為false</h2>
<hr/>
<a href="http://www.dbjr.com.cn" onfocus="getFocus()">腳本之家</a>
<span id="c"></span>
<script language="javascript">
function getFocus(){
document.getElementById("c").innerHTML = document.hasFocus();
}
function Empty_Focus(){
document.getElementById("c").innerHTML = document.hasFocus();
}
</script>
</body>
</html>

相關(guān)文章

最新評(píng)論