JS Popup Code Daquan (detailed collation)

Source: Internet
Author: User

1. Start a full-screen window

Copy CodeThe code is as follows:
<body http://www.jb51.net ', ' the home of the script ', ' fullscreen '); >;
<b>www.jb51.net</b>
</body>


2. Start a window that is F11

Copy CodeThe code is as follows:
<body ' http://www.jb51.net ', ' home of the script ', ' Channelmode '); >;
<b>www.jb51.net</b>
</body>


3. Start a window with the Favorites link toolbar

Copy CodeThe code is as follows:
<body www.wangye8.com ', ' the home of the script ', ' width=400,height=300,directories '); >
<b>www.wangye8.com</b>
</body>


4. Web Page dialog Box

Copy CodeThe code is as follows:
<script language= "JavaScript" >
<!--
ShowModalDialog (' Http://www.jb51.net, ' the home of the script ', ' dialogwidth:400px;dialogheight:300px;
Dialogleft:200px;dialogtop:150px;center:yes;help:yes;resizable:yes;status:yes ')
-
</SCRIPT>
<b>www.wangye8.com</b>
</body>
<script language= "JavaScript" >
<!--
showModelessDialog (' Http://www.jb51.net, ' the home of the script ', ' dialogwidth:400px;dialogheight:300px;
Dialogleft:200px;dialogtop:150px;center:yes;help:yes;resizable:yes;status:yes ')
-
</SCRIPT>
<b>http://www.wangye8.com</b>
</body>


ShowModalDialog () or showModelessDialog () to invoke the Web Page dialog box, the difference between ShowModalDialog () and showModelessDialog () is ShowModalDialog ( The open window (the modal window), which is placed on the parent window, must be closed to access the parent window (it is recommended to use as little as possible to avoid annoying); showModelessDialog ()
Dialogheight:iheight sets the height of the dialog window.
Dialogwidth:iwidth sets the width of the dialog window.
Dialogleft:ixpos sets the left position of the dialog window relative to the upper-right corner of the desktop.
Dialogtop:iypos sets the top position of the dialog window relative to the upper-left corner of the desktop.
Center: {yes | no | 1 | 0} Specifies whether the dialog box is centered on the desktop and the default value is "Yes".
Help: {yes | no | 1 | 0} Specifies whether the dialog window displays a context-sensitive assist icon. The default value is "Yes".
Resizable: {yes | no | 1 | 0} Specifies whether the dialog box window is variable in size. The default value is "no".
Status: {yes | no | 1 | 0} Specifies whether the dialog window displays the status bar. For a modeless dialog window, the default value is "Yes", and for a modal dialog window, the default value is "no".

5, other pop-up window code
Regular Internet friends may have been to some of these sites, the first page will pop up a window, or press a link or button pop-up, usually in this window will show some notes, copyright information, warnings, welcome to patronize the words or the author would like to special prompt information. In fact, it is very easy to make such a page, as long as the page in the HTML to add a few pieces of Java script code can be implemented. I'll take you through the mystery of it.

"The most basic popup window code"
In fact, the code is very simple:

Copy CodeThe code is as follows:
<script language= "java SCRIPT" >
<!--
window.open (' page.html ')
-
</SCRIPT>


Because this is a Java script code, they should be placed between <script LANGUAGE = "java Script" > tags and </script>. <!--and is useful for browsers with low versions, and in these old browsers, if Java script is not supported, the code in the tag is not displayed as text.
window.open (' page.html ') is used to control the popup new window page.html, if page.html is not in the same path as the main window, the path, absolute path (http://) and relative path (. /) are available.
You can use both single and double quotes, just don't mix.
This piece of code can be added anywhere in the HTML, add to
"pop-up window after Setup"
Let's talk about the settings for the appearance of the popup window. Just add a little something to the code above.
Let's customize the appearance, size, and pop-up position of this pop-up window to fit the specific situation of the page.

Copy CodeThe code is as follows:
<script language= "Java script:>
<!--
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= "java Script" > JS script start;
window.open the command that pops up the new window;
page.html the filename of the popup window;
NewWindow the name of the popup window (not the file name), can be replaced by empty ″;
height=100 window height;
The pixel value of the Top=0 window from the top of the screen;
Left=0 the pixel value of the window from the left side of the screen;
Toolbar=no whether the toolbar is displayed, yes is displayed;
Menubar,scrollbars represents the menu bar and scroll bar;
Resizable=no whether the window size is allowed to change, yes is allowed;
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 already open), yes is allowed;
</SCRIPT> js script ends.

"Use function to control pop-up windows"
The following is a complete code.

Copy CodeThe code is as follows:
<script language= "java Script" >
<!--
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 >
... Any page content ...
</body>


A function Openwin () is defined here, and the function content is to open a window. There is no use before calling it. How to invoke it?
Method One: <body > Browser to read the page when the popup window;
Method Two: <body > Pop-up window when the browser leaves the page;
Method Three: Call with a connection: <a href= "#" > Open a Window </a>
Note: The "#" used is a virtual connection.
Method Four: Call with a button: <input type= "button" value= "open Window" >

"main window open file 1.htm, while pop-up small window page.html"
Add the following code to the main window

Copy CodeThe code is as follows:
<script language= "java Script" >
<!--
function Openwin () {
window.open ("page.html", "", "width=200,height=200";)
}
-
</script>


Join <body> area: <a href= "1.htm" >open</a>.

"pop-up window timed off control"
Let's take some control over the popup window, and the effect is even better. If we add a small piece of code to the popup page (note that it is added to page.html HTML, not the main page, otherwise ...) Is it cool to have it automatically shut down after 10 seconds?
First, add the following code to the

Copy CodeThe code is as follows:
<script language= "java Script" >
function Closeit () {
SetTimeout ("Self.close ()", 10000)//MS
}
</script>


Then, and then use <body > This sentence instead of page.html the central Plains have <BODY> this sentence can be. (This sentence must not forget to write Ah!) The function of this sentence is to invoke the code that closes the window, and then close the window on its own after 10 seconds. )

"Add a close button to the pop-up window"

Copy CodeThe code is as follows:
<form>
<input type= ' BUTTON ' value= ' off '
</form>


Oh, now more perfect!
"Included pop-up windows--one page two windows"
The example above contains two windows, one is the main window and the other is a small pop-up window.
In the following example, you can perform the above effect on a page.

Copy CodeThe code is as follows:
<script language= "java SCRIPT" >
function Openwin ()
{
Openwindow=window.open ("", "Newwin", "height=250,width=250,toolbar=no,scrollbars=" +scroll+ ", menubar=no";);
Write a line
OpenWindow.document.write ("<TITLE> example </TITLE>";)
OpenWindow.document.write ("<body bgcolor= #FFFFFF >";)
OpenWindow.document.write ("<H1>Hello!OpenWindow.document.write ("New window opened!";)
OpenWindow.document.write ("</body >";)
OpenWindow.document.write ("</HTML>";)
OpenWindow.document.close ()
}
</script>
<body>
<a href= "#" > Open a Window </a>
<input type= "button" value= "open Window" >
</body>


Look at the code inside OpenWindow.document.write () is not the standard HTML? Just write more lines in the format. It is important to note that more than one label or one label will appear incorrectly. Remember to end with OpenWindow.document.close ().

"The Ultimate app – cookie control for pop-up windows"
Recall, the above pop-up window is cool, but a little bit of a problem (you are immersed in joy, must not find it?) For example, if you put the above script in a page that needs to be frequently passed (such as the homepage), then each time you refresh the page, the window will pop up once, is it annoying? Is there a way to solve it? yes! Follow me. We can use cookies to control it.
First, add the following code to the <HEAD> area of the main page HTML:

Copy CodeThe code is as follows:
<script>
function Openpopup () {
window.open ("hello.htm", "", "width=300,height=300")//Modify the pop-up window yourself
}
function Get_cookie (Name) {
var search = Name + "="
var returnvalue = "";
if (Documents.cookie.length > 0) {
offset = documents.cookie.indexOf (search)
if (offset! =-1) {//if cookie exists
Offset + = Search.length
Set index of beginning of value
End = Documents.cookie.indexOf (";", offset);
Set index of end of cookie value
if (end = =-1)
end = Documents.cookie.length;
Returnvalue=unescape (documents.cookie.substring (offset, end))
}
}
Return returnvalue;
}
function Loadpopup () {
if (Get_cookie (' popped ') = = ") {
Openpopup ()
Documents.cookie= "Popped=yes"
}
}
</script>


Type the following code into the body area:
<body >//pop when leave page
Or:
<body >//pop When enter page
You can try refreshing this page or re-entering the page, and the window will never pop up again. The real pop-only-once!.
Write here, the pop-up window of the production and application skills is basically finished, I hope to be a friend in the making of the web has helped me very happy.
It is important to note that the case in the JS script is best and always consistent.
There are no popup windows for menus, toolbars, and address bars:

Copy CodeThe code is as follows:
<script language= "java Script" >
<!--
var gt = unescape ('%3e ');
var popup = null;
var over = "Launch pop-up Navigator";
Popup = window.open (' ', ' popupnav ', ' Width=500,height=500,resizable=0,scrollbars=auto '); width=500,height=500 for window length and width
if (popup! = null) {
if (Popup.opener = = null) {
Popup.opener = self; }
Popup.location.href = ' filename to open ';
}
-
</script>


Method Two: The application of Cookies: control pop-ups when we set up a pop pop-up in a page, the pop window automatically pops up whenever we re-browse the page, causing unnecessary trouble. So how do we solve this problem? I am here to use a simple example to explain how to make a pop-up window only pop-up when the first time you browse the page, and then no longer annoying!
<script> function Openpopwindow () {window.open ("hello.htm", "" "," width=200,height=200 "//Modify the popup itself} function get_ Cookie (name) {var search = Name + "="; var returnvalue = ""; if (Documents.cookie.length > 0) {offset = documents.cookie.indexOf (search); if (offset! = 1) {///If there was a previous cookie record off Set + = Search.length; Sets the starting position of the cookie end = Documents.cookie.indexOf (";", offset); Sets the end position of the cookie if (end = =-1) end = Documents.cookie.length; Returnvalue=unescape (documents.cookie.substring (offset, end))}} return returnvalue; } function Loadpopup () {if (Get_cookie (' popped ') = = ") {Openpopwindow (); documents.cookie=" Popped=yes ";}} </script& Gt
Type the above code into the body area: <body >//pop-up when leaving the page
Or: <body >//Popup when opening the page

"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and source"
Pop-up window effect when leaving the page:
Effect: When someone closes this page, pop up a window where you can write some blessing words
Core code:

Copy CodeThe code is as follows:
<script language= "JavaScript" >
<!--Begin function leave () {
window.open
(' 1.htm ', ", ' toolbar=no,menubar=no,location=no,height=225,width=235 ');
Break
}
End-->
</script>


How to use the Web page to pop up various forms of windows, I think most of us are aware of some, but the kind of a variety of pop-up window is how to get out, we will learn today:
1. Start a full-screen window

Copy CodeThe code is as follows:
<body http://www.jb51.net ', ' the home of the script ', ' fullscreen '); >;
<b>www.jb51.net</b>
</body>


2. Start a window that is F11

Copy CodeThe code is as follows:
<body ' http://www.jb51.net ', ' home of the script ', ' Channelmode '); >;
<b>www.jb51.net</b>
</body>


3. Start a window with the Favorites Link toolbar

Copy CodeThe code is as follows:
<body www.wangye8.com ', ' the home of the script ', ' width=400,height=300,directories '); >
<b>www.wangye8.com</b>
</body>


4. Web Page dialog box

Copy CodeThe code is as follows:
<script language= "JavaScript" >
<!--
ShowModalDialog (' Http://www.jb51.net, ' the home of the script ', ' dialogwidth:400px;dialogheight:300px;
Dialogleft:200px;dialogtop:150px;center:yes;help:yes;resizable:yes;status:yes ')
-
</SCRIPT>
<b>www.wangye8.com</b>
</body>
<script language= "JavaScript" >
<!--
showModelessDialog (' Http://www.jb51.net, ' the home of the script ', ' dialogwidth:400px;dialogheight:300px;
Dialogleft:200px;dialogtop:150px;center:yes;help:yes;resizable:yes;status:yes ')
-
</SCRIPT>
<b>http://www.wangye8.com</b>
</body>


ShowModalDialog () or showModelessDialog () to invoke the Web Page dialog box, the difference between ShowModalDialog () and showModelessDialog () is ShowModalDialog ( The open window (the modal window), which is placed on the parent window, must be closed to access the parent window (it is recommended to use as little as possible to avoid annoying); showModelessDialog ()
Dialogheight:iheight sets the height of the dialog window.
Dialogwidth:iwidth sets the width of the dialog window.
Dialogleft:ixpos sets the left position of the dialog window relative to the upper-right corner of the desktop.
Dialogtop:iypos sets the top position of the dialog window relative to the upper-left corner of the desktop.
Center: {yes | no | 1 | 0} Specifies whether the dialog box is centered on the desktop and the default value is "Yes".
Help: {yes | no | 1 | 0} Specifies whether the dialog window displays a context-sensitive assist icon. The default value is "Yes".
Resizable: {yes | no | 1 | 0} Specifies whether the dialog box window is variable in size. The default value is "no".
Status: {yes | no | 1 | 0} Specifies whether the dialog window displays the status bar. For a modeless dialog window, the default value is "Yes", and for a modal dialog window, the default value is "no".
5, other pop-up window code
Regular Internet friends may have been to some of these sites, the first page will pop up a window, or press a link or button pop-up, usually in this window will show some notes, copyright information, warnings, welcome to patronize the words or the author would like to special prompt information. In fact, it is very easy to make such a page, as long as the page in the HTML to add a few pieces of Java script code can be implemented. I'll take you through the mystery of it.

"The most basic popup window code"
In fact, the code is very simple:

Copy CodeThe code is as follows:
<script language= "java SCRIPT" >
<!--
window.open (' page.html ')
-
</SCRIPT>


Because this is a Java script code, they should be placed between <script LANGUAGE = "java Script" > tags and </script>. <!--and is useful for browsers with low versions, and in these old browsers, if Java script is not supported, the code in the tag is not displayed as text.
window.open (' page.html ') is used to control the popup new window page.html, if page.html is not in the same path as the main window, the path, absolute path (http://) and relative path (. /) are available.
You can use both single and double quotes, just don't mix.
This piece of code can be added anywhere in the HTML, add to
"pop-up window after Setup"
Let's talk about the settings for the appearance of the popup window. Just add a little something to the code above.
Let's customize the appearance, size, and pop-up position of this pop-up window to fit the specific situation of the page.

Copy CodeThe code is as follows:
<script language= "Java script:>
<!--
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= "java Script" > JS script start;
window.open the command that pops up the new window;
page.html the filename of the popup window;
NewWindow the name of the popup window (not the file name), can be replaced by empty ″;
height=100 window height;
The pixel value of the Top=0 window from the top of the screen;
Left=0 the pixel value of the window from the left side of the screen;
Toolbar=no whether the toolbar is displayed, yes is displayed;
Menubar,scrollbars represents the menu bar and scroll bar;
Resizable=no whether the window size is allowed to change, yes is allowed;
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 already open), yes is allowed;
</SCRIPT> js script ends.

"Use function to control pop-up windows"
The following is a complete code.

Copy CodeThe code is as follows:
<script language= "java Script" >
<!--
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 >
... Any page content ...
</body>


A function Openwin () is defined here, and the function content is to open a window. There is no use before calling it. How to invoke it?
Method One: <body > Browser to read the page when the popup window;
Method Two: <body > Pop-up window when the browser leaves the page;
Method Three: Call with a connection: <a href= "#" > Open a Window </a>
Note: The "#" used is a virtual connection.
Method Four: Call with a button: <input type= "button" value= "open Window" >

"main window open file 1.htm, while pop-up small window page.html"
Add the following code to the main window

Copy CodeThe code is as follows:
<script language= "java Script" >
<!--
function Openwin () {
window.open ("page.html", "", "width=200,height=200";)
}
-
</script>


Join <body> area: <a href= "1.htm" >open</a>.

"pop-up window timed off control"
Let's take some control over the popup window, and the effect is even better. If we add a small piece of code to the popup page (note that it is added to page.html HTML, not the main page, otherwise ...) Is it cool to have it automatically shut down after 10 seconds?
First, add the following code to the

Copy CodeThe code is as follows:
<script language= "java Script" >
function Closeit () {
SetTimeout ("Self.close ()", 10000)//MS
}
</script>


Then, and then use <body > This sentence instead of page.html the central Plains have <BODY> this sentence can be. (This sentence must not forget to write Ah!) The function of this sentence is to invoke the code that closes the window, and then close the window on its own after 10 seconds. )

"Add a close button to the pop-up window"

Copy CodeThe code is as follows:
<form>
<input type= ' BUTTON ' value= ' off '
</form>


Oh, now more perfect!

"included pop-up windows--one page two windows"
The example above contains two windows, one is the main window and the other is a small pop-up window.
In the following example, you can perform the above effect on a page.

Copy CodeThe code is as follows:
<script language= "java SCRIPT" >
function Openwin ()
{
Openwindow=window.open ("", "Newwin", "height=250,width=250,toolbar=no,scrollbars=" +scroll+ ", menubar=no";);
Write a line
OpenWindow.document.write ("<TITLE> example </TITLE>";)
OpenWindow.document.write ("<body bgcolor= #FFFFFF >";)
OpenWindow.document.write ("<H1>Hello!OpenWindow.document.write ("New window opened!";)
OpenWindow.document.write ("</body >";)
OpenWindow.document.write ("</HTML>";)
OpenWindow.document.close ()
}
</script>
<body>
<a href= "#" > Open a Window </a>
<input type= "button" value= "open Window" >
</body>

JS Popup Code Daquan (detailed collation)

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.