다음과 같이 코드 코드를 복사합니다.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<머리>
<title>간단한 이벤트 처리</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="이것은 내 페이지입니다">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--
<script 언어="text/javascript" src="hello.html">이 js의 외부 호출 태그는 단독으로 끝날 수 없습니다.</script>
<link rel="stylesheet" type="text/css" href="./styles.css">
-->
<스크립트 유형="텍스트/자바스크립트">
함수 clickD(obj){
경고(obj.innerHTML);
}
함수 mouseD(obj){
obj.style.color = "#f00";
//코드를 사용하여 스타일을 설정할 때 CSS가 -로 표현되면 카멜 케이스(camel Case)로 표시해야 합니다.
obj.style.fontSize = "16px";
}
함수 outD(obj){
obj.style.color = "#000";
obj.style.fontSize = "18px";
}
//with의 사용법
(문서)와 함께{
write("dddd<br/>");
}
document.write("아아아아<br/>");
document.write("bbbb<br/>");
document.write("cccc<br/>");
</script>
</head>
<본문>
<div onclick="clickD(this)" style="cursor:pointer;">클릭해서 사용해 보세요</div>
<div onmouseover="mouseD(this)" onmouseout="outD(this)">마우스를 움직여 보세요</div>
</body>
</html>
2. 브라우저 개체의 예: "두 브라우저 페이지 간의 값 전송 관련"
다음과 같이 코드 코드를 복사합니다.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<머리>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js01_hello</title>
<meta name="author" content="관리자" />
<스크립트 유형="텍스트/자바스크립트">
// setTimeout("endWelcome()",5000);
// 함수 endWelcome() {
// document.getElementById("welcome").style.display = "none";
// }
</script>
</head>
<본문>
<div id="welcome">저희 웹사이트에 오신 것을 환영합니다</div>
<a href="#" onclick="window.open('test02.html','aaa','width=300,height=300,ressible=0')">test02</a>
<a href="#" onclick="window.open('test03.html','aaa','width=400,height=400,ressible=0')">test03</a>
<br/>
<a href="#" onclick="window.open('bless.html','aaa','width=600,height=300')">축복을 입력하세요</a>
<a href="#" onclick="window.open('bless.html','aaa','width=600,height=300')">성별 선택</a>
<div id="축복"></div>
</body>
</html>
다음과 같이 코드 코드를 복사합니다.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<머리>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js01_hello</title>
<meta name="author" content="관리자" />
<스크립트 유형="텍스트/자바스크립트">
함수 축복() {
//입력된 축복의 말을 가져옵니다.
var mb = document.getElementById("mb").value;
//부모창 얻기
var p = window.opener;
//상위 창에서 id가 bless인 div를 가져옵니다.
var pd = p.document.getElementById("bless");
//pd 값을 설정합니다.
pd.innerHTML = mb;
//현재 창을 닫는다
window.close();
}
</script>
</head>
<본문>
축복의 말 입력:<input type="text" size="40" id="mb"/><input type="button" onclick="bless()" value="input" />
</body>
</html>