Javascript opens a new window and closes the old window

Source: Internet
Author: User

In fact, this problem is closely related to the browser version. As a rookie, I still have not found a perfect solution. No way, because the business must be implemented, so we have to do it in another way:
By redirecting URLs, you can "close" the old window while opening a new window.
Test1.html
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> test1 </TITLE>
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta name = "Author" CONTENT = "">
<Meta name = "Keywords" CONTENT = "">
<Meta name = "Description" CONTENT = "">
</HEAD>
<Script type = "text/javascript">
Function toNewWindow (){
Window. top. location. href = "test2.html ";
}
</Script>
<BODY>
<Input type = "button" value = "open another page test2.html" onclick = "toNewWindow ()">
</BODY>
</HTML>
Test2.html
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> test2.html </TITLE>
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta name = "Author" CONTENT = "">
<Meta name = "Keywords" CONTENT = "">
<Meta name = "Description" CONTENT = "">
</HEAD>
<BODY>
After the URL is rewritten, test2.html
</BODY>
</HTML>
Appendix: page Jump Methods
First:
<Script language = "javascript" type = "text/javascript">
Window. location. href = "/login. jsp? Backurl = "+ window. location. href;
</Script>
Second:
<Script language = "javascript">
Alert ("return ");
Window. history. back (-1 );
</Script>
Third:
<Script language = "javascript">
Window. navigate ("top. jsp ");
</Script>
Fourth:
<Script language = "JavaScript">
Self.location+'top.htm ';
</Script>
Category 5:
<Script language = "javascript">
Alert ("illegal access! ");
Top. location = 'xx. jsp ';
</Script>
===== Jump to other pages through the pop-up selection box in javascript ====
<Script language = "javascript">
<! --
Function logout ()...{
If (confirm ("are you sure you want to log out of your identity? Yes-Select OK, no-select cancel "))...{
Window. location. href = "/logout. asp? Act = logout"
}
}
-->
</Script>
===== Jump to other pages through a prompt box in javascript ====
<Script language = "javascript">
<! --
Function logout ()...{
Alert ("are you sure you want to cancel your identity? ");
Window. location. href = "/logout. asp? Act = logout"
}
-->
</Script>

Related Article

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.