如何使用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. 大小彈出窗口