All Parameters list for window.open ()

Source: Internet
Author: User
Tags html page window
Window|window window.open () List of all parameters
Friends who often surf the internet may visit such websites, a window will pop up immediately, or press a connection or button to pop up, usually in this window will show some attention, copyright information, warning, welcome to patronize such words or the author wants special information. In fact, making such a page effect is very easy, as long as the HTML page to add a few paragraphs of JavaScript code can be achieved. Below I will take you to dissect its mystery.
"1, the most basic pop-up window code"
In fact, the code is very simple:
<script language= "JavaScript" >
<!--
window.open (' page.html ')
-->
</SCRIPT>
Because it's a javascripts code, they should be placed between <script language= "JavaScript" > tags and </script>. <!--and--> are useful for some versions of browsers that do not display the code in the label as text in these old browsers. To develop this good habit ah.
window.open (' page.html ') is used to control the pop-up of the new window page.html, if page.html is not in the same path as the main window, before the path, absolute path (http://) and relative path (...) should be specified. /) are available.
Both single and double quotes are OK, just don't mix.
This piece of code can be added anywhere in HTML,"2, after the Set pop-up window"
Let's say a pop-up window setting. Just add something to the code above.
Let's customize the appearance of this pop-up window, size, popup position to fit the page's specific
Situation
<script language= "JavaScript" >
<!--
window.open (' page.html ', ' newwindow ', ' height=100, width=400, Top=0, left=0, Toolbar=no, Menubar=no, Scrollbars=no, Resizable=no,location=no, Status=no ')
Write a line
-->
</SCRIPT>
Parameter explanation:
<script language= "javascript" > JS script started;
window.open the command to eject a new window;
The filename of the ' page.html ' pop-up window;
' NewWindow ' pop-up window name (not filename), not required, available null ' instead;
height=100 window height;
width=400 window width;
The pixel value of the Top=0 window from the top of the screen;
The pixel value of the left=0 window from the left side of the screen;
Toolbar=no whether the toolbar is displayed, yes for display;
Menubar,scrollbars represents the menu bar and scroll bar.
Resizable=no whether to allow changes to the window size, yes to allow;
Location=no whether the address bar is displayed, yes is allowed;
Status=no whether the information in the status bar is displayed (usually the file is open), yes to allow;
</SCRIPT> JS script End
"3, control pop-up window with function"
The following is a complete code.
<script language= "JavaScript" >
<!--
function Openwin () {
window.open ("page.html", "NewWindow", "height=100, width=400, Toolbar=no, Menubar=no, Scrollbars=no, Resizable=no, Location=no, Status=no "
Write a line
}
-->
</script>
<body onload= "Openwin ()" >
... Any page content ...
</body>
A function Openwin () is defined here, and the function content is to open a window. No prior to calling it
Any use.
How to call it?
Method One: <body onload= "Openwin ()" > Browser pop-up window when reading the page;
Method Two: <body onunload= "Openwin ()" > Browser out of the page pop-up window;
Method Three: Call with a connection:
<a href= "#" onclick= "Openwin ()" > Open a Window </a>
Note: The "#" used is a virtual connection.
Method Four: Use a button to invoke:
<input type= "button" onclick= "Openwin ()" value= "open Window" >
"4, pop-up 2 windows at the same time"
Change the source code a little bit:
<script language= "JavaScript" >
<!--
function Openwin () {
window.open ("page.html", "NewWindow", "height=100, width=100, Top=0,left=0,toolbar=no, Menubar=no, Scrollbars=no, Resizable=no, Location=no, Status=no "
Write a line
window.open ("page2.html", "NewWindow2", "height=100, width=100, top=100, Left=100,toolbar=no, Menubar=no, scrollbars= No, Resizable=no, Location=no, Status=no "
Write a line
}
-->
</script>
To prevent the 2 windows from popping up, use top and left to control the pop-up position and not overwrite each other.
。 The last four methods mentioned above can be invoked.
Note: The name of the 2 windows (NewWindows and NewWindow2) is not the same, or simply all empty.
Ok?
"5, the main window to open the file 1.htm, while pop-up small Windows page.html"
The following code is added to the main window <script language= "JavaScript" >
<!--
function Openwin () {
window.open ("page.html", "" "," width=200,height=200 ")
}
-->
</script>
Join <body> Area:
<a href= "1.htm" onclick= "Openwin ()" >open</a>.
"6, pop-up window of the timing off control"
Below

[1] [2] Next page



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.