JS Close the window or JS close the page several code sharing _javascript tips

Source: Internet
Author: User

The first type: JS timed automatically close the window

Copy Code code as follows:

<script language= "JavaScript" >
<!--
function Closewin () {
Self.opener=null;
Self.close ();}
function Clock () {i=i-1
document.title= "This window will be automatically closed after" +i+ "seconds!";
if (i>0) settimeout ("clock ();", 1000);
else Closewin ();}
var i=10
Clock ();
-->
</script>

The second: Click the link does not prompt JS close the window

Copy Code code as follows:

<a href= "Javascript:self.close ()" > Close window </a>

The Third Kind: The window does not have the prompt to automatically close the JS code
<script language=javascript>
<!--
This.window.opener = null;
Window.close ();
-->
</script>


Third: PHP Code submission window after the prompt information and automatically close the window of the JS code
Copy Code code as follows:

document.write "<script language=javascript>alert" (' Your message sent successfully, we see in time to contact you! '); Opener=null;window.close ();</script> "

Automatically returns the previous page's code:
Copy Code code as follows:

document.write ("<script language=" "JavaScript" ">alert" "your message sent successfully, we see you in time to contact!" ""); History.go ( -1);</script> ")

Ie6-7 JS Close the window does not prompt the method

Method One:
JS Code

Copy Code code as follows:

function Closewin ()//This does not prompt you to close the browser
{
Window.opener=null;
Window.opener=top;
window.open ("", "_self");
Window.close ();
}

Method Two:
Open.html
Copy Code code as follows:

JS Code
function Open_complex_self () {
var Obj_window = window.open (' close.html ', ' _self ');
Obj_window.opener = window;
Obj_window.focus ();
}

Close.html
JS Code
Copy Code code as follows:

Window.close ();

Also attached:
Copy Code code as follows:

Normal with tips off
function Closeie () {
Window.close ();
}
Close IE6 do not prompt
function Closeie6 () {
Window.opener=null;
Window.close ();
}
Close IE7 do not prompt
function Closeie7 () {
window.open (', ' _top ');
Window.top.close ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.