窗口控制JS代码集锦

//本窗口(弹出窗口)关闭,刷新父窗口
<script>window.opener.parent.location.reload();window.close()</script>

//后退一页
<a href="javascript:history.go(-1);">返回前页</a>

//新弹出窗口
<script language=JavaScript>
function newin(url,name,size)
{
 var windowname=window.open(url,name,"left=0,top=0,status=no,scrollbars=no,resizable=no,"+size);
}
</script>
<a href=Javascript:newin('x.htm','Review','width=500,height=400')>查看简介</a>

//页面自动返回
<meta http-equiv="refresh" content="1;url=bigclass.asp">
<p align=center><font color=red>恭喜您!您选择的大类已经被删除!<br>1秒钟后返回上页!</font>

//关闭窗口
<a href="javascript:window.close();">点击这里关闭本窗口</a>

//载入时弹出窗口
<script language="JavaScript">
window.open('http://www.leshanju.6to23.com/','','toolbar,menubar,scrollbars,resizable,status,location,directories,copyhistory

,height=400,width=750');
</script>


//弹出窗口自动关闭
<script language="JavaScript">
  function close() {
  setTimeout("self.close()",10000) //毫秒
  }
</script>

<body onload="close()">

//只弹出一次的窗口
<script>

  function openwin(){
  window.open("page.html","","width=200,height=200")
  }

  function get_cookie(Name) {
  var search = Name + "=" var returnvalue = "";
  if (document.cookie.length > 0) {
  offset = document.cookie.indexOf(search)
  if (offset != -1) {
  offset += search.length
  end = document.cookie.indexOf(";", offset);
  if (end == -1)
  end = document.cookie.length;
  returnvalue=unescape(document.cookie.substring(offset, end))

  }
  }
  return returnvalue;
  }

  function loadpopup(){
  if (get_cookie("popped")=="){
  openwin()
  document.cookie="popped=yes"
  }
  }
</script>

<body onload="loadpopup()">

//控制新开窗口属性
<input type="button" Value="打开新窗口"
ONCLICK="window.open('test.htm', 'Sample',
'toolbar=yes,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=300,height=20

0,left=100,top=100')">

//web窗体对话框
<script language=javascript>
function logonApprove()
{
 var

result=window.showModalDialog("ubbfaces.asp",window,"scroll:no;resizable:no;help:no;status:no;dialogWidth:400px;dialogHeight:

250px");
}



你可能感兴趣的:(窗口控制JS代码集锦)