JS window.open () property

Source: Internet
Author: User

A. Window Object

The Window object is the top-level object in the JavaScript hierarchy.

The Window object represents a browser form or a frame.

The Window object is created on its own initiative at <body> or <frameset> each time it appears.

Two.

The open () method opens a new browser form or finds a named form.

Three.

window.open (Url,name,features,replace)

number of references Descriptive narrative
Url An optional string that declares the URL of the document to display in the new form. Assuming that the parameter is omitted, or if its value is an empty string, the new form will not display any documents.
Name An optional string that is a comma-delimited list of features that contain numbers, letters, and underscores that declare the name of the new form. This name can be used as the value of the tag <a> and <form> property target. Assuming that the parameter specifies a form that already exists, the open () method no longer creates a new form, but simply returns a reference to the specified form. In such a case, the features will be ignored.
Features An optional string that declares the characteristics of the standard browser to be displayed for the new form. Assuming that the parameter is omitted, the new form will have all the standard features. In the form feature this table, we specify the format of the string.
Replace

An optional Boolean value. Specifies whether the URL loaded into the form creates a new entry in the browsing history of the form, or replaces the current entry in the browsing history. The following values are supported:

  • True-url replaces the current entry in the browsing history.
  • False-url creates a new entry in the browsing history.

Four. Form features (Window Features)

Channelmode=yes|no|1|0 Whether to display the form using theater mode. Feel No.
Directories=yes|no|1|0 Whether to join the folder button. Feel yes.
Fullscreen=yes|no|1|0 Whether to use full-screen mode to display the browser. The default is No. A form in full-screen mode must be in theater mode at the same time.
Height=pixels The height of the form document display area. measured in pixels.
Left=pixels The x-coordinate of the form. measured in pixels.
Location=yes|no|1|0 Whether the Address field is displayed. The default is yes.
Menubar=yes|no|1|0 Whether to display the menu bar. The default is yes.
Resizable=yes|no|1|0 Whether the form can be adjusted for dimensions. The default is yes.
Scrollbars=yes|no|1|0 Whether the scroll bar is displayed. The default is yes.
Status=yes|no|1|0 Whether to join the status bar. The default is yes.
Titlebar=yes|no|1|0 Whether the title bar is displayed. The default is yes.
Toolbar=yes|no|1|0 Whether to display the browser's toolbar. The default is yes.
Top=pixels The y-coordinate of the form.
Width=pixels The width of the document display area for the form. measured in pixels.

Five.

Attention:

window.open (Url,name,features,replace)

Assuming name already exists with name, a new form is not created and a reference to the existing form is returned.

Otherwise, a new form is created.

I just didn't pay attention to this, and it took a lot of time to get the pages full-screen.

Six. Detailed business functions

6.1 Open a full-screen form

<script type= "Text/javascript" >

window.open ("http://google.com/", ' new Open Googlewin ', "fullscreen=1")

</script>

6.2 Make this page full screen

Workaround: Open a full-screen target form first, and then close the form.

Code:

<script type= "Text/javascript" >

var url=document.location.href; Get this form property name
Newwin=window.open (URL, ' ', ' fullscreen=1,scrollbars=0 ');
window.opener=null;//out the prompt form when closing
window.open (', ' _self '); Ie7
Window.close ();

</script>

Note: Assuming that you specify the second parameter in the open method and give him a specific value, the second time you use the method above, you will not be able to create a new form, because the default return of the system already exists for the index of the form.

Press ESC to exit full screen

<script type= "Text/javascript" >

ESC exits full Screen
function Exitfullscreenme ()
{
var Esc=window.event.keycode;
if (esc==27)//inference is not pressed by the ESC key, 27 represents the ESC key of the KeyCode.
{
var url=document.location.href;

Win=window.open (URL, ' ', ' Fullscreen=0,directories=1,location=1,menubar=1,resizable=1,scrollbars=1,status=1, Titlebar=1,toolbar=1 '); Make the newly opened form full screen

window.opener=null;//out the prompt form when closing
window.open (', ' _self ');//ie7
Window.close (); Close the old form first

}
}
Document.onkeydown = Exitfullscreenme; Call Hotkey function when onkeydown (key trigger) event occurs

</script>

6.3 Pop up two forms at the same time

<script type= "Text/javascript" >

window.open ("http://google.com/", ' new Open googleWin1 ', "height=300, width=300, Top=0, Left=0,toolbar=no, Menubar=no, Scrollbars=no, Resizable=no, location=n O, Status=no ")

window.open ("http://google.com/", ' new Open googleWin2 ', "height=300, width=300, Top=0, Left=400,toolbar=no, Menubar=no, Scrollbars=no, Resizable=no, location=n O, Status=no ")
</script>

Note: (1) The name of the form cannot be the same, but can be empty;

(2) Note that the layout of the two forms meets your requirements.

6.4

The first time you enter the page, the form pops up. Cookie resolution

First, add the <HEAD> area of the main page HTML, such as the following code:

<script>
function Openwin () {
window.open ("page.html", "", "width=200,height=200")
}
function Get_cookie (Name) {
var search = Name + "="
var returnvalue = "";
if (Document.cookie.length > 0) {
offset = document.cookie.indexOf (search)
if (offset! =-1) {
Offset + = Search.length
End = Document.cookie.indexOf (";", offset);
if (end = =-1)
end = Document.cookie.length;
Returnvalue=unescape (document.cookie.substring (offset, end))
}
}
Return returnvalue;
}
function Loadpopup () {
if (Get_cookie (' popped ') = = ") {
Openwin ()
Document.cookie= "Popped=yes"
}
}
</script>

Then, with <body onload= "Loadpopup ()" > (note not openwin but Loadpop!) Replace the main Page <BODY> this sentence can be. You can try refreshing this page or entering the page again, and the form will never pop up again.

JS window.open () property

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.