如何使用Javascript启用弹出窗口的最大化和恢复按钮?弹出窗口最大化按钮
3
A
回答
4
使用我在底部粘贴的代码,你可以在你的网站界面创建它们仿效这些按钮。
要最大化:使用Namespace.outerPositionGet()
和Namespace.outerSizeGet()
保存当前位置,然后执行Namespace.outerPositionSet({left:0,top:0})
和Namespace.outerSizeSet({width:window.screen.availWidth, height:window.screen.availHeight})
。
恢复:这是最大限度地保存时,刚刚设置的位置和大小。
var Namespace = (function() {
var N, W, framePosition, frameChrome, setFramePosition, setFrameChrome;
N = {};
W = window;
setFramePosition = function() {
var tmp0;
if (typeof framePosition !== 'undefined') {
return;
}
tmp0 = {
top : W.screenTop,
left : W.screenLeft
};
W.moveTo(tmp0.left, tmp0.top);
framePosition = {
top : tmp0.top - W.screenTop,
left : tmp0.left - W.screenLeft
};
W.moveTo(tmp0.left + framePosition.left, tmp0.top + framePosition.top);
};
setFrameChrome = function() {
var tmp0, tmp1;
if (typeof frameChrome !== 'undefined') {
return;
}
tmp0 = N.innerSizeGet();
W.resizeTo(tmp0.width, tmp0.height);
tmp1 = N.innerSizeGet();
frameChrome = {
width : tmp0.width - tmp1.width,
height : tmp0.height - tmp1.height
};
W.resizeTo(tmp0.width + tmp1.width, tmp0.height + tmp1.height);
};
N.outerPositionSet = function(position) {
W.moveTo(position.left, position.top);
};
N.outerPositionGet = function() {
if (typeof W.screenTop !== 'undefined') {
setFramePosition();
N.outerPositionGet = function() {
return {
top : W.screenTop + framePosition.top,
left : W.screenLeft + framePosition.left
};
};
} else if (typeof W.screenY !== 'undefined') {
N.outerPositionGet = function() {
return {
top : W.screenY,
left : W.screenX
};
};
} else {
N.outerPositionGet = function() {
return {
top : 0,
left : 0
};
};
}
return N.outerPositionGet();
};
N.outerSizeSet = function(size) {
W.resizeTo(size.width, size.height);
};
N.outerSizeGet = function() {
if (W.outerWidth) {
N.outerSizeGet = function() {
return {
width : W.outerWidth,
height : W.outerHeight
};
};
} else {
setFrameChrome();
N.outerSizeGet = function() {
var size;
size = N.innerSizeGet();
size.width += frameChrome.width;
size.height += frameChrome.height;
return size;
};
}
return N.outerSizeGet();
};
N.innerSizeSet = function(size) {
setFrameChrome();
N.innerSizeSet = function(size) {
W.resizeTo(size.width + frameChrome.width, size.height + frameChrome.height);
};
N.innerSizeSet(size);
};
N.innerSizeGet = function() {
if (typeof W.innerHeight === 'number') {
N.innerSizeGet = function() {
return {
width : W.innerWidth,
height : W.innerHeight
};
};
return N.innerSizeGet();
}
var isDocumentElementHeightOff, node;
isDocumentElementHeightOff = function() {
var div, r;
div = W.document.createElement('div');
div.style.height = "2500px";
W.document.body.insertBefore(div, W.document.body.firstChild);
r = W.document.documentElement.clientHeight > 2400;
W.document.body.removeChild(div);
return r;
};
if (typeof W.document.clientWidth === 'number') {
node = W.document;
} else if ((W.document.documentElement && W.document.documentElement.clientWidth === 0) || isDocumentElementHeightOff()) {
node = W.document.body;
} else if (W.document.documentElement.clientHeight > 0) {
node = W.document.documentElement;
}
N.innerSizeGet = function() {
return {
width : node.clientWidth,
height : node.clientHeight
};
};
return N.innerSizeGet();
};
return N;
})();
0
你不能,对不起 - 至少,不是普遍。弹出窗口是依赖于实现的,并且没有任何标准的JavaScript方法可以用您描述的方式来控制它。
1
我假设你正在谈论的警报弹出?这不能用标准的JavaScript来完成。
你最好的解决办法是使用一些已经为各种JavaScript框架(如jQuery的)开发了许多弹出的解决方案,并查看是否您可以定制给你的特定用途尝试。
7
你必须打开一个弹出这样的:
window.open('url', 'windowname', 'location=0, status=0, resizable=1, scrollbars=1, width=400, height=400');
诀窍是使窗口调整大小。搜索window.open()函数文档。
1
也试试这个。它的工作对我来说...
window.open('fileURL','status=1,directories=1,menubar=0,toolbar=0,
scrollbars=1,titlebar=0,dialog=1)
相关问题
- 1. 如何禁用window.open弹出窗口中的最大化按钮?
- 2. 在Chrome中最大化弹出窗口
- 3. XLib窗口没有最大化按钮
- 4. 嵌入WebView的Gtk3窗口最大化按钮最大化
- 5. 窗口最大化时弹出窗口内容刷新
- 6. 关闭弹出窗口按钮上的弹出窗口
- 7. 弹出窗口的最大大小
- 8. 点击按钮淡出弹出窗口?
- 9. 从窗口中删除最小化/最大化按钮,OpenTK
- 10. 弹出窗口最大化和关闭,调整大小选项
- 11. 弹出窗口不会指向按钮
- 12. 弹出窗口中的单选按钮
- 13. Kivy弹出窗口和按钮文本
- 14. BootstrapX弹出窗口和关闭按钮
- 15. Facebook发送按钮弹出窗口
- 16. 点击按钮弹出窗口
- 17. 编辑弹出窗口按钮
- 18. 窗口(弹出)在javascript中最小化
- 19. 如何检索窗口最小化,最大化和关闭按钮的大小?
- 20. 如何在点击弹出窗口上的按钮时关闭弹出窗口?
- 21. 如何关闭弹出式窗口中的按钮的自举弹出窗口?
- 22. 如何在关闭该弹出窗口的弹出窗口上制作按钮
- 23. 使用弹出窗口中的按钮关闭Safari弹出窗口
- 24. 与ASP.Net按钮弹出窗口点击,不弹出窗口阻止程序
- 25. 窗口最大化最大化
- 26. 能不能在弹出窗口来控制div时窗口最大化
- 27. 当第二次弹出窗口时,窗口按钮会消失。
- 28. 按钮点击里面的jquery弹出窗口产生窗口
- 29. 从iFrame按钮的父窗口弹出窗口
- 30. 大小弹出窗口