本文为大家详细介绍下 js 中关于简单事件的处理与浏览器对象,下面有个不错的示例,感兴趣的朋友可以参考下
Javascript 是一种由 Netscape 的 LiveScript 发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如 Perl,遗留的速度问题,为客户提供更流畅的浏览效果。
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">
- <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">
- 欢迎进行我们的网站
- </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')">
- 输入你祝福语
- </a>
- <a href="#" onclick="window.open('bless.html','aaa','width=600,height=300')">
- 选择性别
- </a>
- <div id="bless">
- </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">
- <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() {
- //获取输入的祝福语
- 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>
- <body>
- 输入祝福语:
- <input type="text" size="40" id="mb" />
- <input type="button" onclick="bless()" value="输入" />
- </body>
- </html>
来源: