Fokus jendela () metode
Definisi dan Penggunaan
() Metode fokus untuk memberikan keyboard fokus jendela.
tatabahasa
window.focus()
Dukungan Browser
Semua browser utama mendukung fokus () metode
contoh
contoh
Pastikan bahwa jendela baru menerima fokus (sebelum mengirim jendela baru):
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
berfungsi openWin () {
MyWindow = window.open ( '', '', 'width = 200, height = 100');
myWindow.document.write ( "<p> Ini adalah 'jendela' </ p>");
myWindow.focus ();
}
</ Script>
</ Kepala>
<Body>
<Input type = "button" value = "jendela yang terbuka" onclick = "openWin ()" />
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
berfungsi openWin () {
MyWindow = window.open ( '', '', 'width = 200, height = 100');
myWindow.document.write ( "<p> Ini adalah 'jendela' </ p>");
myWindow.focus ();
}
</ Script>
</ Kepala>
<Body>
<Input type = "button" value = "jendela yang terbuka" onclick = "openWin ()" />
</ Body>
</ Html>
Coba »
contoh yang lebih
Pastikan bahwa jendela baru tidak mendapatkan fokus
objek jendela