如果您打开这样的窗口并同时打开记事本,新窗口将在记事本下方打开。
我想知道如何在任何其他窗口之上打开一个新窗口。添加 window.focus()
不起作用..
setTimeout(function() {
window.open('http://google.com', 'google new window', 'width:10');
}, 5000);
最佳答案
试试这个 -
window.open(url, "_blank", "resizable=yes, scrollbars=yes, titlebar=yes, width=800, height=900, top=10, left=10");
The open() method creates a new secondary browser window, similar to choosing New Window from the File menu. The strUrl parameter specifies the URL to be fetched and loaded in the new window. If strUrl is an empty string, then a new blank, empty window (URL about:blank) is created with the default toolbars of the main window.
Note that remote URLs won't load immediately. When window.open() returns, the window always contains about:blank. The actual fetching of the URL is deferred and starts after the current script block finishes executing. The window creation and the loading of the referenced resource are done asynchronously.
var windowObjectReference;
var strWindowFeatures = "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes";
function openRequestedPopup() {
windowObjectReference = window.open("http://www.cnn.com/", "CNN_WindowName", strWindowFeatures);
}
var windowObjectReference;
function openRequestedPopup() {
windowObjectReference = window.open(
"http://www.domainname.ext/path/ImageFile.png",
"DescriptiveWindowName",
"resizable,scrollbars,status"
);
}
If a window with the name already exists, then strUrl is loaded into the existing window. In this case the return value of the method is the existing window and strWindowFeatures is ignored. Providing an empty string for strUrl is a way to get a reference to an open window by its name without changing the window's location. On Firefox and Chrome (at least), this only works from the same parent, ie. if the current window is the opener of the window you try to get an handle on. Otherwise the call to window.open() will just create a new window.
To open a new window on every call of window.open(), use the special value _blank for strWindowName.
关于javascript - 如何使用 JavaScript 在其他窗口之上打开一个新窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60202119/