admin管理员组

文章数量:1313157

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=submit name="submit"value="submit">
    </form>
  </body>
</html>

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=submit name="submit"value="submit">
    </form>
  </body>
</html>
Share Improve this question edited Mar 24, 2011 at 4:09 Prisoner 27.6k11 gold badges76 silver badges103 bronze badges asked Mar 24, 2011 at 4:03 PrabakaranPrabakaran 2214 gold badges9 silver badges19 bronze badges 1
  • 1 When you have an answer that works for you, you should accept it as an answer. – Ateş Göral Commented Mar 24, 2011 at 4:09
Add a ment  | 

4 Answers 4

Reset to default 4

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.

本文标签: