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

  • Bratayley

    Bratayley

    30 Aralık 2010
  • Incredible Tutorials

    Incredible T

    27 EKİM 2006
  • SavageLuxxxGaming - Daily NBA 2K15 & NBA Live 15 Enjoy And Subscribe!

    SavageLuxxxG

    11 Ocak 2013