开发者

How to automatically close the parent window when the child window is opened in Firefox

i have this code i need to close the parent.html window when the child window opened, i need the code for that working well in IE and Firefox

Parent.html

<HTML>
  <SCRIPT TYPE="text/javascript">
  function sendTo()
  {
  window.open('child.html','_blank','resizable=yes,width='+(screen.width-500)+',height='+(screen.height-500)+'');

  }
  </SCRIPT>
  <BODY>
  <form name="form">
    <input type="text" value="" name="text1" id="pdetails1">
    <input type="text" value="" name="text1" id="pdetails2">
    </br>
    <input type="submit" value="submit" onClick="sendTo()">
  </BODY>
</HTML>

child.html

<html>
  <body>
    <form>
      <input type=text name="text5" value="">
      <input type=s开发者_JAVA百科ubmit name="submit"value="submit">
    </form>
  </body>
</html>


in child:

<script type="text/javascript">
window.opener.close();
</script>

Most browsers won't let you, however.


try this

Parent Window:

<script type="text/javascript">
function sendTo()
{
window.open('child.html','_blank','resizable=yes,width='+(screen.width-500)+',height='+(screen.height-500)+'');
this.window.close();

}
</SCRIPT>

OR In Child window

<script type="text/javascript">
window.opener.close()
</SCRIPT>


Do this. First open the current window to trick your current tab into thinking it has been opened by a script. Then close it using window.close(). The below script should go into the parent window, not the child window. You could run this after running the script to open the child.

<script type="text/javascript">
    window.open('','_parent',''); 
    window.close();
</script>


Step 1 : Type the in address bar as " about:config " and press enter key

Step 2: "i'll be careful , I promise" Click on this button

Step 3: " dom.allow_scripts_to_close_windows " Search this line and Double click on it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜