中心的Window.popup在浏览器中对齐 [英] Window.popup in center align in browser
本文介绍了中心的Window.popup在浏览器中对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个动态产生的Div数据. 我想在某些事件触发后在弹出窗口中打开该div数据. 我的代码已经完成.但是,当在浏览器中打开弹出窗口时,它没有居中对齐.
我的代码:-
var w = 620;
var h = 360;
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var divText = document.getElementById("inviteConfirmationMessage").outerHTML;
var myWindow = window.open('','','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
var doc = myWindow.document;
doc.open();
doc.write(divText);
doc.close();
在Mozilla firefox中工作,但在Chrome中不工作-
请帮帮我!或任何指导.
解决方案
var left = (window.screen.width / 2) - ((w / 2) + 10);
var top = (window.screen.height / 2) - ((h / 2) + 50);
window.open('','',
"status=no,height=" + height + ",width=" + width + ",resizable=yes,left="
+ left + ",top=" + top + ",screenX=" + left + ",screenY="
+ top + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
I have a Div data which is coming dynamically. I want to open that div data in popup after some event fired. I am done with my code. But when popup is opening in my browser its not centered aligned.. Its coming in corner..
My code :-
var w = 620;
var h = 360;
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var divText = document.getElementById("inviteConfirmationMessage").outerHTML;
var myWindow = window.open('','','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
var doc = myWindow.document;
doc.open();
doc.write(divText);
doc.close();
Working in Mozilla firefox but not working in Chrome --
Please help me out !! or any guidance.
解决方案
var left = (window.screen.width / 2) - ((w / 2) + 10);
var top = (window.screen.height / 2) - ((h / 2) + 50);
window.open('','',
"status=no,height=" + height + ",width=" + width + ",resizable=yes,left="
+ left + ",top=" + top + ",screenX=" + left + ",screenY="
+ top + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
这篇关于中心的Window.popup在浏览器中对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文