In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to customize the new window by JavaScript". In the daily operation, I believe many people have doubts about how to customize the new window by JavaScript. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to customize the new window by JavaScript". Next, please follow the editor to study!
The basic syntax structure of the window.open () method is:
Window.open (sURL, sName)
However, you can customize the new window by using 2 additional parameters:
Window.open (sURL, sName [, sfeatures] [, bReplace])
By omitting these parameters, you can use the default features. Let's first look at the bReplace parameter, which is only supported by Inte.NET Explorer:4 and later versions. This parameter is useful only if the second parameter names an existing window. It is a Boolean value, if true, it means that the URL specified by the first parameter replaces the address where the current window browsing location is saved in history, and if false, a new project is created in the window's browsing history (this is the default). This parameter is not very useful because it is only supported by Microsoft browsers. Let's take a look at the well-known nature of Javascript window settings.
The third argument to the open () method is a string containing a comma-separated list of options (without any spaces). Before entering the ocean of available features, let's take a look at what they mean. Here's an example:
Win = window.open ("http://www.docjs.com/"," docjs "," location=1,menubar=1,resizable=1 ")
This statement opens a variable-sized window with an address bar and a menu bar, while other features are turned off. For example, if the status feature is not specified, the new window does not have a status bar. Note that there are several other ways to define window features. Here are a few commands that are equivalent to the previous statement:
Win = window.open ("http://www.docjs.com/"," docjs "," location,menubar,resizable ")
Win = window.open ("http://www.docjs.com/"," docjs "," location=yes,menubar=yes,resizable=yes ")
Win = window.open ("http://www.docjs.com/"," docjs "," location,menubar=1,resizable=yes ")
Many features can be yes or no. For these features, you can also use 1 instead of yes,0 instead of no. If you want to activate a feature, you can also simply list the name of the feature in the sFeatures string. If it is not listed, it means that the feature is blocked (except titlebar and hotkeys). The sFeatures parameter is a comma-separated list of features that should not contain any spaces or white space characters. Each element in the list should contain the following format:
Feature [= value]
There is a big difference between assigning an empty string to the sFeatures parameter and omitting it altogether. If the call to open () has no arguments, then all features are set to default values. In other words, the browser will create a window with the default width and height, standard menus, toolbars, and other browser features. If you use an empty string as a list of required features, the browser will open a window with all its features blocked (except titlebar and hotkeys).
The second parameter sName of the window.open () method specifies the name of the window. If it is the name of an existing window, the browser loads the specified URL (sURL) in that window. So, if sName specifies a window that exists, the browser ignores the list of defined features.
Not all window features can be supported by all browsers. If the browser does not recognize the specified feature, it simply ignores it. Let's take a look at the definitions of the various window features in JavaScript:
Web/2001/01/19/58_1607.html#alwaysLowered "> alwaysLowered innerWidth screenY alwaysRaised left scrollbars channelmode location status dependent menubar titlebar directories outerWidth toolbar fullscreen outerHeight top height menubar width hotkeys resizable z-lock innerHeight screenX
AlwaysLowered
Internet Explorer: not supported
Navigator: version 4 +
Specifies that the window always remains at the bottom of the stack. In other words, whether a new window is active or not, it is always under another window.
Window.open ("alwayslowered.html", "_ blank", "alwaysLowered")
AlwaysRaised
Internet Explorer: not supported
Navigator: version 4 +
Specifies that the window always remains at the top of the stack. In other words, whether a new window is active or not, it is always on another window.
Window.open ("alwaysraised.html", "_ blank", "alwaysRaised")
Channelmode
Internet Explorer: version 4 +
Navigator: not supported
Specifies whether the window is displayed in theater mode, and whether the channel area is displayed.
Window.open ("channelmode.html", "_ blank", "channelmode")
Dependent
Internet Explorer: not supported
Navigator: version 4 +
Defines whether the window becomes a dependent child window of the currently open window. A dependent window is that when its parent window closes, it also closes. On windows platforms, a dependent window is not displayed on the taskbar.
Window.open ("dependent.html", "_ blank", "dependent")
Directories
Internet Explorer: all versions
Navigator: all versions
Specifies whether catalog buttons (such as the well-known "What's Cool" and "What's New" button) are displayed. Internet Explorer refers to these catalog buttons as link toolbars, and Navigator (version 4 and above) calls them personal toolbars.
Window.open ("directories.html", "_ blank", "directories")
Fullscreen
Internet Explorer: version 4 +
Navigator: not supported
Defines whether to open the browser in full screen mode. Please use full screen mode carefully, because in this mode, the browser's title bar and menu are hidden, so you should provide a button or other visual clue to help the user close the window. Of course, windows can also be closed by using the hotkey ALT+F4.
Window.open ("fullscreen.html", "_ blank", "fullscreen")
Height
Internet Explorer: all versions
Navigator: all versions
Defines the height of the display area of the window document in pixels pixel, with a minimum value of 100. If you define only the height, Internet Explorer uses the given height and default width. For Navigator, if you do not specify width or innerWidth at the same time, this attribute will be ignored.
Window.open ("height.html", "_ blank", "height=200,width=300")
Hotkeys
Internet Explorer: not supported
Navigator: version 4 +
If it is not defined (or 0), then most of the hotkeys in new windows without menu bars are blocked. But the security and exit hotkeys remain.
Window.open ("hotkeys.html", "_ blank", "hotkeys=0,menubar=0")
InnerHeight
Internet Explorer: not supported
Navigator: version 4 +
Defines the height of the display area of the window document in pixels pixel, with a minimum value of 100. In Navigator version 4, this feature replaces height in order to maintain backward compatibility. For Navigator, if you do not specify width or innerWidth at the same time, this attribute will be ignored.
Window.open ("innerheight.html", "_ blank", "innerHeight=200,innerWidth=300")
InnerWidth
Internet Explorer: not supported
Navigator: version 4 +
Defines the width of the display area of the window document in pixels pixel, with a minimum value of 100. In Navigator version 4, this feature replaces width in order to maintain backward compatibility. For Navigator, if you do not specify height or innerHeight at the same time, this attribute will be ignored.
Window.open ("innerwidth.html", "_ blank", "innerHeight=200,innerWidth=300")
Left
Internet Explorer: version 4 +
Navigator: not supported
Defines the X left label of the window in pixels.
Window.open ("left.html", "_ blank", "left=20")
Location
Internet Explorer: all versions
Navigator: all versions
Defines whether to display the text fields in the browser for address URL input.
Window.open ("location.html", "_ blank", "location")
Menubar
Internet Explorer: all versions
Navigator: all versions
Defines whether the menu bar is displayed (the menu bar is at the top of the window, including File, Edit, and so on).
Window.open ("menubar.html", "_ blank", "menubar")
OuterHeight
Internet Explorer: not supported
Navigator: version 4 +
Defines the total height of the window (its outer boundary) in pixels, with a minimum value greater than 100, because the height of the window content area must be at least 100. This feature will be ignored if outerWidth,Navigator is not defined at the same time.
Window.open ("outerheight.html", "_ blank", "outerHeight=200,outerWidth=300")
OuterWidth
Internet Explorer: not supported
Navigator: version 4 +
Defines the total width of the window (its outer boundary) in pixels, with a minimum value greater than 100, because the width of the window content area must be at least 100. This feature will be ignored if outerHeight,Navigator is not defined at the same time.
Window.open ("outerwidth.html", "_ blank", "outerHeight=200,outerWidth=300")
Resizable
Internet Explorer: all versions
Navigator: all versions
Defines whether the window can be resized through its boundaries. Depending on the platform, users may have other ways to resize the window.
Window.open ("resizable.html", "_ blank", "resizable")
ScreenX
Internet Explorer: not supported
Navigator: version 4 +
Defines the X coordinates of the window in pixels.
Window.open ("screenx.html", "_ blank", "screenX=20")
ScreenY
Internet Explorer: not supported
Navigator: version 4 +
Defines the Y coordinates of the window in pixels.
Window.open ("screeny.html", "_ blank", "screenY=20")
Scrollbars
Internet Explorer: all versions
Navigator: all versions
Defines whether horizontal and vertical scroll bars are activated.
Window.open ("scrollbars.html", "_ blank", "scrollbars")
Status
Internet Explorer: all versions
Navigator: all versions
Defines whether to add a status bar to the lower part of the window.
Window.open ("status.html", "_ blank", "status")
Titlebar
Internet Explorer:Version 5 +
Navigator: version 4 +
Defines whether the title bar of the window is displayed. In Internet Explorer, this feature is blocked unless the caller is a HTML application or a trusted dialog box.
Window.open ("titlebar.html", "_ blank", "titlebar=0")
Toolbar
Internet Explorer: all versions
Navigator: all versions
Defines whether the browser's toolbar is displayed (at the top of the window, including "back" and "forward").
Window.open ("toolbar.html", "_ blank", "toolbar")
Top
Internet Explorer: version 4 +
Navigator: not supported
Defines the ordinate of the window in pixels.
Window.open ("top.html", "_ blank", "top=20")
Width
Internet Explorer: all versions
Navigator: all versions
Defines the width of the display area of the window document in pixels pixel, with a minimum value of 100. If you define only the width, Internet Explorer uses the given width and the default height. For Navigator, if you do not specify height or innerHeight at the same time, this attribute will be ignored.
Window.open ("width.html", "_ blank", "height=200,width=300")
Z-lock
Internet Explorer: not supported
Navigator: version 4 +
Defines that the window does not float in the stack when activated, that is, the new window cannot be on top of other windows when activated.
Window.open ("zlock.html", "_ blank", "z-lock")
At this point, the study on "how to customize the new window for JavaScript" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.