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

javascript hasFocus使用實(shí)例

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

<html>
<head>
<title>Dom:hasFocus方法實(shí)例</title>
</head>
<body onfocus="getFocus()" onblur="Empty_Focus()">
<h2>請點(diǎn)擊網(wǎng)頁區(qū)域.表明該網(wǎng)頁獲得焦點(diǎn),顯示為true.點(diǎn)擊瀏覽器地址欄.該網(wǎng)頁失去焦點(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)文章

最新評論