笔记:js对象

来源:互联网 发布:python exit code非0 编辑:程序博客网 时间:2024/06/04 00:40


navigator 管理者浏览器的版本号和使用的语言等信息
window 处于顶级位置,每个对象代表一个浏览器窗口
location 含有当前网页的url地址
document 含有当前网页的各种特性
history 含有以前访问过的网页的url地址

 

--------------------navigator

1.appName
2.appCodename
3.appVerson

<script language="javascript">document.write(navigator.appName + "<br>" + navigator.appCodename + "<br>" + navigator.appVerson);</script>


--------------------window
window.confirm("....")  //弹出确定框
window.prompt("....", '0') //弹出提示框
window.alert(...);  //警告窗口
window.open(url, name, features); //打开浏览器窗口

 

<script language="javascript">function checkform() {if(confirm("确定提交吗?"))return true;else return false;}</script><form name="form1" action="2.html" method="post" onsubmit="return checkform()"><input type="submit" value="提交" /></form>

 

<script language="javascript">var a, b;var c=0;a=prompt("input a number:", '0');//0为默认值b=prompt("input a number:", '0');c=parseInt(a)+parseInt(b);document.write(a+"+"+b+"="+c);</script>

 

<script language="javascript">function MM_popMsg(msg){alert(msg);}</script><a href="#" onmousedown="MM_popMsg('弹出了一个警告框也!')">弹出警告框</a>

 

<script language="javascript">function MM_openBrWindow(theURL,winName,features) { //v2.0  window.open(theURL,winName,features);}</script><img src="images/1.jpg"/><img src="images/1.jpg" onclick="MM_openBrWindow('images/1.jpg','放大的图片','toolbar=yes,width=800,height=800')"  />



---------------------------------------location

<script language="javascript">document.write(location.href);document.write(location.host);document.write(location.hostname);document.write(location.port);document.write(location.protocal);</script>


 

<script language="javascript">document.write(location.href +"<br>");document.write(location.host +"<br>");document.write(location.hostname +"<br>");document.write(location.port +"<br>");document.write(location.protocal +"<br>");document.write(location.search +"<br>");document.write(location.pathname +"<br>");</script><form action="#" method="post">    <input type="button" onclick="window.location.search='a+b+c';" value="search"/>    <input type="button" onclick="window.location.href='2.html';" value="href"/>    </form>


-----------------------history

<form action="#" method="post">    <input type="button"  value="前进1" onclick="history.forward()" />    <input type="button"  value="后退1" onclick="history.back()" /></form>


 

<form action="#" method="post">    <input type="button"  value="前进2" onclick="history.go(1)" />    <input type="button"  value="后退2" onclick="history.go(-1)" /></form>


---------------------------document

script language="javascript">function xxx() {window.alert(document.links(0).href);//连接的地址window.alert(document.anchors.length);//锚点的长度}</script><a href="http://www.bai.com">baidu</a><a href="javascript:xxx()" >show</a>


 

<form name="zxw"><input type="text" onchange="document.form1.elements[0].value=this.value;" /></form><form name="form1"><input type="text" onchange="document.forms[0].elements[0].value=this.value;" /></form>



 

原创粉丝点击