Home > Web Front-end > JS Tutorial > javascript window.open solution to the problem that the window cannot be opened again after opening a new window_javascript skills

javascript window.open solution to the problem that the window cannot be opened again after opening a new window_javascript skills

WBOY
Release: 2016-05-16 16:52:32
Original
1509 people have browsed it

In the system, javascript open window is used in some places. For example, opening a fixed-mode window prevents users from performing other operations.

Parameters:

Copy code The code is as follows:

Parameters | Value range | Description
alwaysLowered | yes/no | The specified window is hidden behind all windows
alwaysRaised | yes/no | The specified window is suspended above all windows
depended | yes/no | Whether to close at the same time as the parent window
directories | yes/no | Whether the directory bar of Nav2 and 3 is visible
height | pixel value | window height
hotkeys | yes/no | Set safe exit hotkey in a window without menu bar
innerHeight | pixel value | The pixel height of the document in the window
innerWidth | pixel value | The pixel width of the document in the window
location | yes/no | Whether the location bar is visible
menubar | yes/no | Whether the menu bar is visible
outerHeight | pixel value | Set the pixel height of the window (including decorative borders)
outerWidth | pixel value | Set the pixel width of the window (including decorative borders)
resizable | yes/no | Whether the window size is Adjustable
screenX | pixel value | The pixel length of the window from the left edge of the screen
screenY | pixel value | The pixel length of the window from the upper edge of the screen
scrollbars | yes/no | Whether the window can have scroll bars
titlebar | yes/no | Whether the window title bar is visible
toolbar | yes/no | Whether the window toolbar is visible
Width | pixel value | The pixel width of the window
z-look | yes/no | Whether the window floats above other windows after being activated

Example:
Copy code The code is as follows:
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")

Open after calculating the height and width according to the resolution:
Copy codeThe code is as follows:
var ht = screen.height-98;
var widhh = screen.width - 20;
window.opener = null;
window.open("" , "_self");
window.open("Main.aspx", "newwindow" JsGuid(),
"height=" ht ", width=" widhh ",
depended=yes,top =0,left=0,toolbar=no, menubar=no,
scrollbars=yes, resizable=no, location=no, status=yes");

window.close();

And close the original window.

Question:

After window.open, if the system exits, an error will occur when using window.open to open a new page again.

I googled for a long time and couldn’t find it. Thinking that this problem should not happen often, it must be a configuration problem.

Among them, we can see that the second parameter of window.open is the name of the new window. This name cannot be repeated.

If it is repeated, keep opening and refreshing this window.

So I added a js random GUID function.

Copy code The code is as follows:
function s4() {
return Math.floor((1 Math.random()) * 0x10000)
.toString(16)
.substring(1);
};
function JsGuid() {
return s4() s4() ' -' s4() '-' s4() '-'
          s4() '-' s4() s4() s4();
}

Use: window when opening a window .open("Main.aspx", "newwindow" JsGuid());
OK, the problem is solved.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template