JavaScript:windowオブジェクト常用方法とイベント
10062 ワード
<html>
<head>
<meta charset="UTF-8">
<title>JavaScript:window title>
<script type="text/javascript">
// =============================
window.onload = function () {//
this.open_fix_adv();
}
//window , window , window
window.setTimeout(function () {
console.dir("5s ");
}, 5000);
window.setInterval(function () {
console.dir(" 2s ");
}, 2000);
function open_adv() {
window.open("../html/01.html");
}
function open_fix_adv() {
window.open("../html/01.html", "", "height=380,width=320,left=800,top=200,toolbar=0,
scrollbars=0,location=0, status=0,menubar=0,resizable=0");
}
function fullscreen() {
window.open("../html/01.html", "", "fullscreen=1");
}
function close_adv() {
window.close();
}
//
function confirm_msg() {
var flag = window.confirm("are u sure?");
console.dir(flag);
}
// =============================
function getonChangeVal() {
var name = document.getElementById("username").value;
var x = document.getElementsByName('username');
console.dir(x[0].value);
console.dir(name);
}
function getonKeyDown() {
var x = document.getElementById("age").value;
console.dir(x);
}
function getonMouseOver() {
console.dir('onmouseover');
}
function printStr() {
console.dir("onload ");
}
script>
head>
<body style="text-align: center;" onload="printStr()">
<input type="button" name="open1" onclick="open_adv()" value=" "/>
<br/><br/>
<input type="button" name="open1" onclick="open_fix_adv()" value=" , "/>
<br/><br/>
<input type="button" name="open1" onclick="confirm_msg()" value=" "/>
<br/><br/>
<input type="button" name="open1" onclick="fullscreen()" value=" "/>
<br/><br/>
<input type="button" name="open1" onclick="close_adv()" value=" "/>
<br/><br/>
<input type="text" name="username" id="username" onchange="getonChangeVal()" value="jack"/>
<br/><br/>
<input type="text" name="age" id="age" onkeydown="getonKeyDown()" value="10"/>
<br/><br/>
<p onmousedown="getonMouseOver()"> p>
body>
html>