问题
I am opening an popup in Javascript with:
function popup(title,w,h,site) {
x = screen.availWidth/2-w/2;
y = screen.availHeight/2-h/2;
var date = new Date()
var ticks = date.getTime();
var popupWindow = window.open(
title,"popup"+ticks,'width='+w+',height='+h+',left='+x+',top='+y+',screenX='+x+',screenY='+y+',resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes,titlebar=yes,hotkeys=yes,status=yes,dependent=no,location=1');
popupWindow.document.write(site);
return popupWindow;
}
When I right click the new window, the "save as"-dialog is deactivated in chrome.
How can I enable it? What am I doing wrong?
回答1:
the attribute status
should be 1
not yes
. This should be what is preventing Chrome from treating the popup as a new window.
Also, open()
takes parameters in this order:
window.open(URL,name,specs,replace)
So try:
window.open("about:blank", title, 'width='+w+',height='+h+',left='+x+',top='+y+',screenX='+x+',screenY='+y+'resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes,titlebar=yes,hotkeys=yes,status=yes,dependent=no,location=1')
来源:https://stackoverflow.com/questions/11416646/javascript-popup-chrome-save-as-deactivated-why