弹出窗口最大化按钮(Popup window Maximize button)

编程入门 行业动态 更新时间:2024-10-08 00:24:09
弹出窗口最大化按钮(Popup window Maximize button)

如何使用Javascript启用弹出窗口的最大化和恢复按钮?

How to enable the maximize and restore button of the popup window using Javascript?

最满意答案

使用粘贴在底部的代码,您可以通过在网站界面中创建这些按钮来模拟这些按钮。

要最大化:使用Namespace.outerPositionGet()和Size保存当前位置,然后使用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; })();

Using the code I pasted on the bottom, you can emulate these buttons by creating them in your website interface.

To maximise: save the current position with Namespace.outerPositionGet() and size with Namespace.outerSizeGet(), then do Namespace.outerPositionSet({left:0,top:0}) and Namespace.outerSizeSet({width:window.screen.availWidth, height:window.screen.availHeight}).

To restore: just set position and size which were saved when maximising.

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; })();

更多推荐

本文发布于:2023-08-07 11:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464140.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弹出窗口   按钮   Popup   button   Maximize

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!