Javascript 使用javascript隐藏窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5180684/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hidden window using javascript
提问by user475685
Just wanted to know if it is possible to create a hidden window using javascript?
只是想知道是否可以使用 javascript 创建隐藏窗口?
采纳答案by Andrey
You can create an iframe
您可以创建一个 iframe
var element = document.createElement("iframe");
element.setAttribute('id', 'myframe');
document.body.appendChild(element);
You can hide an iframe by setting its width and height to zero or by setting its visibility to hidden in the stylesheet.
您可以通过将 iframe 的宽度和高度设置为零或将其可见性设置为在样式表中隐藏来隐藏 iframe。
回答by Tonino
You can also create a new window visible only in taskbar with this workaround:
您还可以使用以下解决方法创建一个仅在任务栏中可见的新窗口:
window.open(path.html,'_blank', 'toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10000, top=10000, width=10, height=10, visible=none', '');
that open a window in a position not visible by user. I have used this trick different times.
在用户不可见的位置打开窗口。我曾多次使用过这个技巧。
回答by PlattBob3
Under IE 9+ you can create a window off-screen:
在 IE 9+ 下,您可以在屏幕外创建一个窗口:
var options = "left=" + (screen.width*2) + ",top=0";
var myWin = window.open(url, name, options);
// Hide the window - IE only
myWin.blur();
// Show the window - IE only
myWin.focus();
screen.width is your monitor width. Using "*2" allows for users with dual monitors.
screen.width 是您的显示器宽度。使用“*2”允许使用双显示器的用户。
This does not work under Chrome.
这在 Chrome 下不起作用。