Script编程window对象以及this的用法

prompt对话框
<html>
	<head>
		<title>
		函数
		</title>
	<Script language="JavaScript">
	var userName = prompt("请输入你的名字:");
  	document.write("你好!"+userName);
	</Script>
	
	</head>
	<body>
	</body>
</html>


confirm对话框

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
	//while(true)
		///alert("ghahah");

	function confirmit()
	{
		var obj=document.getElementById("testa");
		if(confirm("你确认删除此文件么?"))
		{
			obj.submit();
		} 
  }  	
	</Script>	
	</head>
	<body>
	<form id="testa" action="ttt.jsp" method="post">
		<input type="button" value="删除文件" οnclick="confirmit()" name="aaa">
	</form>
	</body>
</html>


<html>
	<head>
		<title>
		函数
		</title>
	<Script language="JavaScript">
	function confirmit()
	{
  	if(confirm("你确认删除此文件么?"))
  	{
  		document.testa.submit();
  	} 
  }  	
	</Script>	
	</head>
	<body>
	<form name="testa" action="ttt.jsp" method="post">
		<input type="button" value="删除文件" οnclick="confirmit()" name="aaa">
	</form>
	</body>
</html>

this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<!--prompt提示comfirm认证submit提交status状态-->
<Script type="text/javascript">
function checkit(obj)
{
	if(obj.value=="")
	{
		alert("空值");
	}
	else
	{
		alert(obj.value);
	}
}
</Script>
</head>
	
<body>
	<img src="1.jpg" οnclick="alert(this.src);">
	<form >
		<input type="text"  value="ddaaa" οnclick="checkit(this)">
	</form>
</body>
</html>

///

下面的很少用

window.status

鼠标经过的时候

<html>
	<head>
		<title>
		本地窗口
		</title>
	
	</head>
	<body οnlοad="window.status='Hello,Please look here!'"><!--状态栏body的状态属性-->

	
	<form name="ttt">
		<input type="button" value="test" onMouseOver="window.status='haha';">
	</form>
	</body>
 </html>


new windiow

前面是位置,后面是大小

<html>
	<head>
		<title>
		新开窗口
		</title>
	
	</head>
	<body>
	<Script language="JavaScript">
	window.open("1.htm","newWin","toolbar=no,left=200,top=100,menubar=no,width=100,height=100,resizable=no");
	//window.open("1.htm","newWin","toolbar=no,left=200,top=100,menubar=no,width=100,height=100,resizable=no");
	//window.open("1.htm");
	</Script>
	</body>
</html>


focus()close()

<html>
	<head>
		<title>
		新开窗口
		</title>
	
	</head>
	<body>
	<Script language="JavaScript">
	var abc = window.open("1.htm","newWin","toolbar=no,left=200,top=100,menubar=no,width=300,height=100");
	</Script>
	<input type="button" οnclick="JavaScript:abc.focus();" value="跑前面来">
	<input type="button" οnclick="JavaScript:abc.close();" value="关闭">
	</body>
</html>



 window.location

网页的位置

<html>
	<head>
		<title>
		本地窗口
		</title>
	
	</head>
	<body>
	<Script language="JavaScript">
	//alert(window.location);
	alert(document.location.href);
	</Script>
	</body>
</html>


<html>
	<head>
		<title>
		本地窗口
		</title>
	
	</head>
	<body>
	<Script language="JavaScript">
	function go2()
	{
	  window.location="33.htm";
	}
	</Script>
	<input type="button" value="转向" οnclick="JavaScript:go2()">
	</body>
</html>

history.back();

<html>
	<head>
		<title>
		本地窗口
		</title>
	
	</head>
	<body>
	<Script language="JavaScript">
	function goBack()
	{
	  history.back();
	}
	</Script>
	<input type="button" value="返回" οnclick="JavaScript:goBack()">
	</body>
</html>



 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值