Copy the code code as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Simple event handling</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--
<script language="text/javascript" src="hello.html">The external call tag of this js cannot end by itself</script>
<link rel="stylesheet" type="text/css" href="./styles.css">
-->
<script type="text/javascript">
function clickD(obj){
alert(obj.innerHTML);
}
function mouseD(obj){
obj.style.color = "#f00";
//When using code to set styles, if the css is represented by -, it must be marked with camel case font-size -> fontSize
obj.style.fontSize = "16px";
}
function outD(obj){
obj.style.color = "#000";
obj.style.fontSize = "18px";
}
//Usage of with
with(document){
write("dddd<br/>");
}
document.write("aaaa<br/>");
document.write("bbbb<br/>");
document.write("cccc<br/>");
</script>
</head>
<body>
<div onclick="clickD(this)" style="cursor:pointer;">Click and try it</div>
<div onmouseover="mouseD(this)" onmouseout="outD(this)">Try moving the mouse</div>
</body>
</html>
2. Example of browser object: "Involving value transfer between two browser pages"
Copy the code code as follows:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js01_hello</title>
<meta name="author" content="Administrator" />
<script type="text/javascript">
// setTimeout("endWelcome()",5000);
// function endWelcome() {
// document.getElementById("welcome").style.display = "none";
// }
</script>
</head>
<body>
<div id="welcome">Welcome to our website</div>
<a href="#" onclick="window.open('test02.html','aaa','width=300,height=300,resizable=0')">test02</a>
<a href="#" onclick="window.open('test03.html','aaa','width=400,height=400,resizable=0')">test03</a>
<br/>
<a href="#" onclick="window.open('bless.html','aaa','width=600,height=300')">Enter your blessing</a>
<a href="#" onclick="window.open('bless.html','aaa','width=600,height=300')">Select gender</a>
<div id="bless"></div>
</body>
</html>
Copy the code code as follows:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js01_hello</title>
<meta name="author" content="Administrator" />
<script type="text/javascript">
function bless() {
//Get the input blessing words
var mb = document.getElementById("mb").value;
//Get the parent window
var p = window.opener;
//Get the div with id bless in the parent window
var pd = p.document.getElementById("bless");
//Set the value of pd
pd.innerHTML = mb;
//Close the current window
window.close();
}
</script>
</head>
<body>
Enter blessing words:<input type="text" size="40" id="mb"/><input type="button" onclick="bless()" value="input" />
</body>
</html>