JavaScript Popup Chrome 'save as'-deactivated? Why?

亡梦爱人 提交于 2019-11-30 15:25:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!