bjyzxxds 发表于 2013-2-7 02:02:19

JS关于刷新父页面例子

javascript 弹出页面点击确定,刷新父页面 仔细分析学习:

  a.htm

<input type=buttonvalue=http://blog.soso.com/qz.q/"showModalDialog open"/> <input type=buttonvalue=http://blog.soso.com/qz.q/"open"/>

  b.htm

<input type=button value=http://blog.soso.com/qz.q/refresh /> <script language="javascript" type="text/javascript">  function a()  {  window.parent.dialogArguments.document.execCommand('Refresh');  }  </script>

  --------------------------------------
  <script language="javascript" type="text/javascript">  function get()  {  window.parent.dialogArguments.document.execCommand('Refresh');  }  function shut()  {  window.parent.dialogArguments.document.execCommand('Refresh');  window.close();   }  </script>  <input type=button value=http://blog.soso.com/qz.q/提交 />  <input type=button value=http://blog.soso.com/qz.q/关闭 />

  -----------------------------------------------------------

  1: 关闭窗口

  <input type="button" name="close" value=http://blog.soso.com/qz.q/"关闭窗口" >

  2: 列印窗口

  <input type="button" name="print" value=http://blog.soso.com/qz.q/"列印窗口" >

  3: 返回上一页

  <input type="button" name="back" value=http://blog.soso.com/qz.q/"返回上页" >

  4: 开新窗口

  <input type="button" name="open" value=http://blog.soso.com/qz.q/"开新窗口" >

  5: 刷新页面

  5-1: 刷新本页

  <input type="button" name="slef" value=http://blog.soso.com/qz.q/"刷新本页" >

  5-2: 刷新父页

  <input type="button" name="par" value=http://blog.soso.com/qz.q/"刷新父页" >

  5-3: 刷新父页的另一个框架中的页面

  <input type="button" name="parIt" value=http://blog.soso.com/qz.q/"刷新父页另一框架" >

  5-4: 刷新另一个框架中的页面

  <input type="button" name="parFrame" value=http://blog.soso.com/qz.q/"刷新另一框架" >

  6: 提示

  6-1: 单一"确定"按钮提示,点击后继续下面的代码

  <script>
  alert("操作成功!");
  alert("操作失败!");
  </script>

  6-2: 选择提示,确定或者取消,分支语句.

  <script>  if (confirm("您确定吗?"))  alert("您点的是确定!");  else  alert("您点的是取消!");  </script>

  7:光棒

  <tr bgcolor="ecf2f9"   onMouseOut="style.backgroundColor='ecf2f9';"   >

  8:客户端数据验证.

  用form提交的数据可直接在客户端進行一些相关的完全和安全性验证,如名称不能为空,料号是8位数,有效的email地址等..,可以快速的反应并减轻server的负载.

  <script>  function datacheck() {  var msg = ""; //这个是用于显示错误提示  var obj = ""; //这个是记录错误的输入值,用于出错时返加focus  with(document.form1){ //共用对象,本页面的form1  if (name.value=http://blog.soso.com/qz.q/="")  {  msg = "\n name的值不能为空";  obj = "name";  }  if (partno.value.length!=8)  {  msg = "\n partno的长度应该是8位";  obj = "partno";  }  //=================================================================  if(msg!="")  {  mobj = eval(obj);  mobj.focus();  alert("输入错误\n"+msg);  return(false);  }  else  {  action="用于接受数据的下一页"  submit();  }  }  }  </script>   <form name="form1" method="post">  <input type="text" name="name">  <input type="text" name="partno">

  '下面的按钮用于提交数据,但按钮类型为button,调用datacheck()函数,datacheck()用于检验用于输入的数据是正确,如果正确则提交下一页,否则不提交,返回focus定于错误的text.

  <input type="button" name="Submit" value=http://blog.soso.com/qz.q/"Submit" >  <input type="reset" name="reset1" value=http://blog.soso.com/qz.q/"Reset">  </form>

  父页是显示标题,弹出页修改标题提交后,父页更新:

  <script language=javascript>  function winclose() {  window.opener.location.reload();  window.close();  }  </script>  <input type=button name=close value=http://blog.soso.com/qz.q/"关闭" onclick=winclose()>

  =============================

  <script>   function op(){   newopen=window.open("post.php","0","0");   setInterval('wen()',10);   }   function wen(){   if(newopen.closed){   window.location.reload();   }   }   </script>  <span style="CURSOR: hand" onclick='op()'>打开关闭</span>
页: [1]
查看完整版本: JS关于刷新父页面例子