[英]showmodaldialog definition from Chromium source code
Google Chrome has removed the support for showmodaldialog function described at the following blog URL. Google Chrome删除了以下博客URL中描述的对showmodaldialog功能的支持。 http://blog.chromium.org/2014/07/disabling-showmodaldialog.html
http://blog.chromium.org/2014/07/disabling-showmodaldialog.html
My webpages have few errors and I am thinking that if I can get the implementation of the showmodaldialog and put it on my base master page. 我的网页几乎没有错误,我在想,如果我可以实现showmodaldialog的实现并将其放在基础母版页上。
I am trying to download the source code from https://chromium.googlesource.com/chromium/src but getting some SSL errors: unable to get local issuer certificate. 我正在尝试从https://chromium.googlesource.com/chromium/src下载源代码,但遇到一些SSL错误:无法获取本地发行者证书。
Can anybody provide me the source code of the said method and it's dependent methods so that I can use that directly on my webpages to show the popup. 谁能提供给我上述方法及其相关方法的源代码,以便我可以直接在我的网页上使用它来显示弹出窗口。
I put the following javascript in the page header and it seems to work. 我将以下javascript放在页面标题中,它似乎可以正常工作。 It detects when the browser does not support showModalDialog and attaches a custom method that uses window.open, parses the dialog specs (height, width, scroll, etc.), centers on opener and sets focus back to the window (if focus is lost).
它检测浏览器何时不支持showModalDialog,并附加一个使用window.open的自定义方法,解析对话框规格(高度,宽度,滚动等),以打开器为中心,然后将焦点设置回窗口(如果焦点丢失) )。 If you are passing window args to the modal you will need to write some additional code to fix that.
如果要将窗口args传递给模态,则需要编写一些其他代码来解决该问题。 The popup is not modal but at least you don't have to change a lot of code.
弹出窗口不是模态的,但至少您不必更改很多代码。 Might need some work for your circumstances.
根据您的情况可能需要做一些工作。
<script type="text/javascript">
// fix for deprecated method in Chrome 37
if (!window.showModalDialog) {
window.showModalDialog = function (arg1, arg2, arg3) {
var w;
var h;
var resizable = "no";
var scroll = "no";
var status = "no";
// get the modal specs
var mdattrs = arg3.split(";");
for (i = 0; i < mdattrs.length; i++) {
var mdattr = mdattrs[i].split(":");
var n = mdattr[0];
var v = mdattr[1];
if (n) { n = n.trim().toLowerCase(); }
if (v) { v = v.trim().toLowerCase(); }
if (n == "dialogheight") {
h = v.replace("px", "");
} else if (n == "dialogwidth") {
w = v.replace("px", "");
} else if (n == "resizable") {
resizable = v;
} else if (n == "scroll") {
scroll = v;
} else if (n == "status") {
status = v;
}
}
var left = window.screenX + (window.outerWidth / 2) - (w / 2);
var top = window.screenY + (window.outerHeight / 2) - (h / 2);
var targetWin = window.open(arg1, arg1, 'toolbar=no, location=no, directories=no, status=' + status + ', menubar=no, scrollbars=' + scroll + ', resizable=' + resizable + ', copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
targetWin.focus();
};
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.