Reputation: 5813
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.
Upvotes: 2
Views: 23499
Reputation: 6124
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");
Upvotes: 4
Reputation: 1652
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);
you are missing last quote in it.
Is should be like this :
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+');
Upvotes: -2