Similar to thinkbox and lightbox. Displays pages, images, or other content in a unique mode dialog box. This is its official website: http://orangoo.com/labs/GreyBox/
Let's take a look at several of its instances:
(1) Open the webpage:
(2) display a group of images:
Basic usage
(1) Go to the official website and click to download
(2) decompress the package. (The installation.html describes the use of the tool, which is easy to understand at a glance. Write down the steps)
(3) copy the greybox folder to the root directory of the web project,Note:: Be sure to put it under the web root directory and put it under another directory or level-2 directory. It is deployed in my project as follows:
(By the way, I put it in the js folder at first, because my js scripts are all in it, and jQuery is also in it, but it cannot be used... Finally, you can use it in the root directory .)
(4) Now we can use it. We use a test page for testing. The Code is as follows:
Copy codeThe Code is as follows: <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Title> test.html </title>
<! -- GreyBox reference starts -->
<Script type = "text/javascript">
Var GB_ROOT_DIR = "./greybox/"; // note the path here !!!
</Script>
<Script type = "text/javascript" src = "greybox/AJS. js"> </script>
<Script type = "text/javascript" src = "greybox/AJS_fx.js"> </script>
<Script type = "text/javascript" src = "greybox/gb_scripts.js"> </script>
<Link href = "greybox/gb_styles.css" rel = "stylesheet" type = "text/css"/>
<! -- GreyBox reference ended -->
</Head>
<Body>
<A href = "http://www.baidu.com" title = "Baidu" rel = "gb_page [500,500]"> Baidu </a>
</Body>
</Html>
This completes the basic usage.
However, in actual development, we need to achieve this effect: (1) click the button to bring up the mode window; (2) Close the mode window and refresh the parent window.
Through basic usage, we can see that the examples on the official website are displayed after clicking a hyperlink.
And so on.
However, for actual development, we sometimes need to click the Button to bring up a modal dialog box. In fact, you can implement it with a slight modification. Since the previous article has already explained the usage, this time the Code is directly added:
(1) Click the implementation button to bring up the modal dialog box.
Copy codeThe Code is as follows: <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Title> test.html </title>
<! -- GreyBox reference starts -->
<Script type = "text/javascript">
Var GB_ROOT_DIR = "./greybox/"; // note the path here !!!
</Script>
<Script type = "text/javascript" src = "greybox/AJS. js"> </script>
<Script type = "text/javascript" src = "greybox/AJS_fx.js"> </script>
<Script type = "text/javascript" src = "greybox/gb_scripts.js"> </script>
<Link href = "greybox/gb_styles.css" rel = "stylesheet" type = "text/css"/>
<! -- GreyBox reference ended -->
<Script type = "text/javascript">
// The Center dialog box appears.
Function openWinCenter (){
// GB_showCenter (caption, url,/* optional */height, width, callback_fn)
GB_showCenter ("Baidu", "http://www.baidu.com", 600,900 );
}
// The modal window is displayed in full screen mode.
Function openWinFull (){
// GB_showFullScreen (caption, url, callback_fn)
GB_showFullScreen ("Baidu", "http://www.baidu.com ");
}
</Script>
</Head>
<Body>
<Input type = "button" value = "center pop-up" onclick = "openWinCenter ()"> <br/>
<Input type = "button" value = "full screen pop-up" onclick = "openWinFull ()"> <br/>
</Body>
</Html>
For detailed Usage, see the "Advance Usage" section in the official document.
(2) This problem occurs during development. After the operation is performed in the pop-up window, you must refresh the parent window when closing the window. How to implement it?
Let's take a look at how common js is written.Copy codeThe Code is as follows: <script language = "javascript">
// Pop-up window
Function openSubWin (){
Window. open ("", "name1", "width = 100, height = 200, toolbar = no, scrollbars = no, menubar = no, screenX = 100, screenY = 100 ");
}
// Close the Child Window and refresh the parent window
Function closeSubWin (){
Window. opener. location = "http://www.baidu.com ";
Window. close ();
}
</Script>
How can we implement GreyBox? On the code, [note] This js is written in the webpage of the subwindow:Copy codeThe Code is as follows: <script type = "text/javascript">
Function close (){
Parent. parent. location. reload ();
Parent. parent. GB_hide ();
}
</Script>
Now, we have finished learning GreyBox, which can meet our daily project needs.