JavaScript window.open Open a new window (different name) in the original window _javascript tips

Source: Internet
Author: User
Tags ukey

A recent JSP Web page requires opening an IE without a menu toolbar, thinking of using window.open to open. However, if the previously opened form is not turned off, a new form is opened on a form that has not been closed before, so that the previous window is replaced. After finding data and testing found that when you open a form, the name of the form you specify will open on that form when you have the same name as the current one. For example, the following situation:

window.open ("View_svg.jsp?ukey=<%=ukey%>&itemid=<%=itemid%>&charset=utf-8", "NewWindow"), " Height= ' 100% ', width= ' 100% ', toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=no,status= No ");
Each of these open forms opens in a form named NewWindow.

Note: The name of the form is different from the title.

1.window.open (urlstr, ' _blank ', ');

The _blank parameter represents opening a new window.

2. You can also use the following method to make each open form a different name.

<%
Random rd = new Random ();
int i = Rd.nextint (+1);
String ranstr = string.valueof (i);
%>
<script type= "text/javascript" >
function Doclose () {
 var currnwin = window.open ("View_ Svg.jsp?ukey=<%=ukey%>&itemid=<%=itemid%>&charset=utf-8 "," <%=ranStr%> "," height= ' 100% ', width= ' 100% ', Toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=no,status=no ');
Window.opener=null;
 Window.close ();
 Window.focus ();
}
</script>

Here's an introduction to using JavaScript window.open to open a new window

The open () method can find a browser window that already exists or is new.

Grammar:

window.open ([URL], [window name], [parameter string])

Parameter description:

URL: Optional parameter, in the window to display the Web page URL or path. If this argument is omitted, or if its value is an empty string, the window does not display any documents.

Window name: Optional parameter, the name of the window to be opened.

1. The name consists of letters, numbers, and underscore characters.
2. The name "_top", "_blank" and "_selft" have special meanings.
_blank: Display the target page in a new window
_self: Display the target page in the current window
_top: frames page Displays the destination page in the upper window
3. Windows with the same name can only be created one, and name cannot be the same if you want to create more than one window.
4.name cannot contain spaces.

Parameter string: Optional argument, set window parameters, separated by commas.

Parameter table:

For example: Open http://www.baidu.com Web site, size 300px * 200px, no menus, no toolbars, no status bar, scroll bar window:

<script type= "Text/javascript" > window.open (' http://www.baidu.com ', ' _blank ', ' width=300,height=200,menubar= No,toolbar=no, Status=no,scrollbars=yes ')
</script>

Friendly reminder: This must pay attention to the compatibility of the browser problem ha.

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.