JS Close the window and JS close the page of several methods summary _javascript skills

Source: Internet
Author: User

The first type: JS timed automatically close the window
<script language= "JavaScript" >
<!--
function Closewin ()
{
Self.opener=null;
Self.close ();
}
function Clock ()
{
I=i-1
document.title= "This window will automatically close 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
<a href= "Javascript:window.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>


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

Method One:
JS Code
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
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
Window.close ();

Attach:
//normal with prompt close
function Closeie () {
Window.close ();
}
//Close IE6 not prompt
function closeie6 () {
Window.opener=null;
Window.close ();
}
//Close IE7 does 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.