Created
April 2, 2012 19:43
-
-
Save h4/2286667 to your computer and use it in GitHub Desktop.
События в JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type=”text/javascript”> | |
function yourMessage(){ | |
alert("Функция"); | |
} | |
</script> | |
</head> | |
<body onload="yourMessage()"> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript"> | |
function show_coords(event) | |
{ | |
x=event.clientX; | |
y=event.clientY; | |
alert("X coords: " + x + ", Y coords: " + y); | |
} | |
</script> | |
</head> | |
<body onmousedown="show_coords(event)"> | |
<p>Щелкните кнопкой мыши.</p> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript"> | |
function whichButton(event) { | |
alert(event.keyCode); | |
} | |
</script> | |
</head> | |
<body onkeyup="whichButton(event)"> | |
<p>Нажмите клавишу на клавиатуре.</p> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<script type="text/javascript"> | |
function scope_mem() { | |
var a = 20; | |
document.onclick = function(){alert(a); }; | |
} | |
scope_mem(); | |
</script> | |
</head> | |
<body> | |
<p>Текст документа.</p> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html> | |
<head> | |
<title>event bubbling</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<script type="text/javascript"> | |
function fun_div(){ | |
alert("event in div"); | |
} | |
function fun_span(){ | |
alert("event in span"); | |
} | |
</script> | |
</head> | |
<body> | |
<div onclick = "fun_div();"> | |
<span onclick = "fun_span();">Место для щелчка</span></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment