JavaScript / jQuery: eğer pencere odağı varsa Test | Netgez.com
SORU
13 AÄžUSTOS 2010, Cuma


JavaScript / jQuery: eğer pencere odağı varsa Test

Nasıl eğer tarayıcı odağı varsa test musun?

CEVAP
13 AÄžUSTOS 2010, Cuma


belgenin hasFocus yöntemi kullanın. Detaylı açıklama ve örnek burada bulabilirsiniz: hasFocus method

DÜZENLEME:Eklenen keman http://jsfiddle.net/Msjyv/3/

HTML

Currently <b id="status">without</b> focus...

JS

function check()
{
    if(document.hasFocus() == lastFocusStatus) return;

    lastFocusStatus = !lastFocusStatus;
    statusEl.innerText = lastFocusStatus ? 'with' : 'without';
}

window.statusEl = document.getElementById('status');
window.lastFocusStatus = document.hasFocus();

check();
setInterval(check, 200);

Bunu PaylaÅŸ:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • kruno j

    kruno j

    6 Mayıs 2007
  • Rozetked | Обзоры

    Rozetked | Ð

    5 AÄžUSTOS 2011
  • TSE

    TSE

    12 Kasım 2012