问题
I'm opening a Popup, it opens in internet explorer and mozilla firefox. But firefox ignores the given sizes, so a fullscreen popup is created.
Following code:
<a href="agb.html" target="_blank" onclick="return popup(this.href);">linkname</a>
Following function:
<script type="text/javascript">
function popup (url) {
fenster = window.open(url, "Popup", "width=640,height=700,resizable=yes,scrollbars=yes");
fenster.focus();
return false;
}
</script>
回答1:
This is what I have on a dev site which I know at works in Firefox (actually it's the only thing I have tested it on. I don't know too much about js, so I'm sure I got this from the web somewhere- so hopefully it follows correct practices and what not.
// js:
<script type="text/javascript">
// Popup window code
function newPopup(url) {
popupWindow = window.open(
url,'popUpWindow','height=390,width=350,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}
</script>
// link: edit: an onclick event should be used instead, but I'm leaving my original code.
<a href="Javascript:newPopup('/url/');">Link text</a>
回答2:
I'm having a similar problem with a form submitted to a popup. I have
<form name ="printView" method ="post" action="printOnly.php" target="popUp"
onsubmit="popup(this);" style="display:inline!important;">
(the style is to get the form on the same line as another form)
And the popup function is
function popup(form) {
window.open('','formpopup', 'view text',
'height=700,width=640,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes'
);
form.target = 'formpopup';
view.focus(this);
}
As you can see I have tried the top and left options, but my popup still opens at the same size as the main window, and the scrollbar, toolbar, menubar, directories and location settings are disregarded, I get only the location bar no matter what I set their values to. PS. I checked Firefox popup preferences and they are all allowed.
回答3:
You need to make the display property of your popup to be either display: block;
or display: inline-block
for your width and height dimensions to take effect.
回答4:
<a href="agb.html" target="_blank" onclick="popup(this.href);return false;">linkname</a>
will do what you want ;)
来源:https://stackoverflow.com/questions/6873887/pop-up-window-opens-fullscreen-in-firefox-though-sizes-are-given