A boundless box window (CW) without border and menu bar, toolbar, address bar, status bar, etc., is very popular, and is adopted by many websites, especially personal websites, CW also has ready-made source code for netizens, but The initial CW is very inconvenient, there are two JS files, but also set some parameters, which is very difficult for some beginners. So I have an idea: rewrite a new boundless box window, only one function is implemented, for users to use.
I gave this new boundless frame window named NBW, NBW, NO BORDER WINDOW, just wants to distinguish between CW. This boundless box window can be dragged, minimize, close, etc., not only in IE5 / IE6, not only testing in Tencent TE.
First look at the actual effect:
The process of call is as follows: (the Noborderwin function is defined in advance, and the implementation process of the function will be analyzed later)
Titlebg: Window "Title Bar" background color and window border color.
MoveBG: Drag the background color of the "Title Bar" when the window and the window border color.
Titlecolor: The color of the "Title Bar" text.
TitleWord: The text displayed in the Window "Title Bar".
SCR: Whether the scroll bar is displayed in the window. Value YES / NO or 1/0.
We see that all window styles are set in the parameters of the function, thereby ensuring the convenience of use. For example, the code of the above example is as follows:
How to use it, then how is this function implementation? Below, we explain in a way that directly gives the edition and comment. In order to easily distinguish reading, the code section uses gray, and the comment portion uses red.
// ***** Customize the path to several images used in the NBW window *****
Minimizebar = "minimize.gif"; // Minimize "Button" in the upper right corner of the window
Minimizebar2 = "minimize2.gif"; // minimize "button" when the mouse hover
Closebar = "close.gif"; // Turn off the "button" in the upper right corner of the window
Closebar2 = "close2.gif"; // Picture of the "button" when the mouse is hover
icon = "icon.gif"; // Small icon in the upper left corner of the window
// *************** Customized end **************** // ******* Start to define noborderwin () function********
Function Noborderwin (FileName, W, H, Titlebg, MoveBG, Titlecolor, Titleword, SCR)
{
VAR Contents = "" // Variable Contents is a string variable, which is all of the code in the NBW window.
"
"
"
" TitleWord " Title>"
"
"
Head> "
"
// In order to make the window more realistic, in this sentence, the drag and drop events and selection events are dispersed.
"
" / / In this sentence, any drag of the NBW window is realized, pay attention to what "happened" when OSEDOWN, ONMOUSEUP, and ONMOUSEMOVE, carefully understand the process. "
td>"
" Titleword " span> Td> " // The two sentences are written to the text of the small icon and the title bar.
"
td> " // Implement the function of the window to close the button.
TR> "
"
"
"
"
" Td>"
Tr> "
" Table>"
" Body>"
" Html>";
// Hehae, it has already defined the CONTENTS variable, after we will see: it is written to the NBW window.
POP = WINDOW.Open ("", "_ blank", "fullscreen = yes"); // Open a full screen window.
Pop.resizEther (w, h); // uses the resize () method to customize the window into the size you want.
POP.Moveto (Screen.Width-W) / 2 (Screen.Height-h) / 2); // Move the window to the center of the screen with the MoveTo () method.
Pop.Document.writeln (CONTENTS); // Write the window content (ie, variable contents).
// Here, maybe you think it should be over. Indeed, in IE, it is indeed end, but in the multi-window browser (such as Tencent's TE), the general window .Open () is not popping up, but appears in it One window in "Multi-Window", so we will judge whether the NBW window is a separate window through the window size, if not, we will use the showmodaldialog () dialog as a transition, re "play" Out of a separate window.
If (pop.document.body.clientwidth! = w || pop.document.body.clientHeight! = h) // determines whether NBW is truly a separate window by judging the actual size of the NBW window. If not, the following statement will be run.
{
Temp = WINDOW.OPEN ("", "NBW_V6");
Temp.close (); // The function of the two sentences is if there is a window of Name = NBW_V6, turn it off.
Window.ShowModaldialog ("About: <" "script language = javascript> window.open ('', 'nbw_v6', 'fullscreen = yes'); window.close ();" "" "script> ",", "Dialogwidth: 0px; Dialogheight: 0px"); // Pop up a dialog, then pop up a Name = NBW_V6 from the dialog box, note that the window will definitely be a separate window. POP2 = WINDOW.OPEN ("NBW_V6"); // Pop up a window of Name = NBW_V6, because the full screen window of Name = NBW_V6 is popped up, so this time the window is only refreshed in that window. In this way, the window is assigned to the variable POP2.
POP2.ResizETO (W, H); // Use the resize () method to customize the window into the size you want.
Pop2.moveto (Screen.Width-W) / 2, (Screen.Height-h) / 2); // Move the window to the center of the screen with a MoveTo () method.
POP2.Document.writeln (CONTENTS); // Write the window content (ie, the variable contents).
Pop.close (); // will turn off the window that is not really "bomb".
}
// ******* End definition Noborderwin () function ********}
At this point, all code is explained. We can see that we use the IFRAME tag in the implementation, so the current NBW window is only used in IE and uses in a browser using the IE kernel.
In addition, I also made an instance to everyone to make it easy to use, click here to download.
The first time I wrote this window. It was about two months. During this period, I have made five changes in this period. In the process of constant revision, I have got a lot of friends and netizens, and I am sincere gratitude to them. !