笔记:js对象


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" οnsubmit="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="#" οnmοusedοwn="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" οnclick="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" οnclick="window.location.search='a+b+c';" value="search"/>
    <input type="button" οnclick="window.location.href='2.html';" value="href"/>
    
</form>


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

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


 

<form action="#" method="post">
    <input type="button"  value="前进2" οnclick="history.go(1)" />
    <input type="button"  value="后退2" οnclick="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" οnchange="document.form1.elements[0].value=this.value;" />
</form>
<form name="form1">
	<input type="text" οnchange="document.forms[0].elements[0].value=this.value;" />
</form>



 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值