我怎样才能让在Chrome 37 window.showmodaldialog工作? [英] How can I make window.showmodaldialog work in chrome 37?

查看:325
本文介绍了我怎样才能让在Chrome 37 window.showmodaldialog工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们必须在这里我们使用 window.showmodaldialog 警报,确认和弹出一个巨大的Web应用程序。由于37的Chrome版本这一呼吁已被禁用。

We have a huge web application where we use window.showmodaldialog for alerts, confirmations and popups. Since Chrome version 37 this call has been disabled.

有没有快速的解决方法,使 window.showmodaldialog 在Chrome最新版本的工作?

Is there any quick workaround to make window.showmodaldialog work in the latest version of Chrome?

我在这里增加了对window.showmodaldialog一种变通方法,虽然这不是一个完美的解决办法,因为这不会打破code作为执行是在showModalDialog这样做,而是这将打开弹出窗口。

I am adding here a workaround for window.showmodaldialog, although this is not a perfect workaround because this will not break the code execution as showmodaldialog was doing, instead this will open the popups.

window.showModalDialog = function (url, arg, feature) {
        var opFeature = feature.split(";");
       var featuresArray = new Array()
        if (document.all) {
           for (var i = 0; i < opFeature.length - 1; i++) {
                var f = opFeature[i].split("=");
               featuresArray[f[0]] = f[1];
            }
       }
        else {

            for (var i = 0; i < opFeature.length - 1; i++) {
                var f = opFeature[i].split(":");
               featuresArray[f[0].toString().trim().toLowerCase()] = f[1].toString().trim();
            }
       }



       var h = "200px", w = "400px", l = "100px", t = "100px", r = "yes", c = "yes", s = "no";
       if (featuresArray["dialogheight"]) h = featuresArray["dialogheight"];
        if (featuresArray["dialogwidth"]) w = featuresArray["dialogwidth"];
       if (featuresArray["dialogleft"]) l = featuresArray["dialogleft"];
        if (featuresArray["dialogtop"]) t = featuresArray["dialogtop"];
        if (featuresArray["resizable"]) r = featuresArray["resizable"];
       if (featuresArray["center"]) c = featuresArray["center"];
      if (featuresArray["status"]) s = featuresArray["status"];
        var modelFeature = "height = " + h + ",width = " + w + ",left=" + l + ",top=" + t + ",model=yes,alwaysRaised=yes" + ",resizable= " + r + ",celter=" + c + ",status=" + s;

        var model = window.open(url, "", modelFeature, null);

       model.dialogArguments = arg;

    }

只是把这个code在页​​面的头部分。

Just put this code in the head section of page.

推荐答案

从<一个href=\"http://$c$ccorner.galanter.net/2014/09/02/reenable-showmodaldialog-in-chrome/\">http://$c$ccorner.galanter.net/2014/09/02/reenable-showmodaldialog-in-chrome/

这是由设计pcated德$ P $。您可以重新启用在showModalDialog的支持,但只是暂时的 - 直到2015年利用这段时间的5月创建的替代解决方案。

It's deprecated by design. You can re-enable showModalDialog support, but only temporarily – until May of 2015. Use this time to create alternative solutions.

下面是如何做到这一点在Chrome的Windows。打开注册表编辑器(regedit),并创建以下项:

Here’s how to do it in Chrome for Windows. Open Registry Editor (regedit) and create following key:

<$c$c>HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Google\\Chrome\\EnableDe$p$pcatedWebPlatformFeatures

EnableDe precatedWebPlatformFeatures 键创建<$ C与名的字符串值 1 和价值$ C> ShowModalDialog_EffectiveUntil20150430 。要验证策略中启用,访问chrome://政策网址。



更新:如果上面没有你这里的尝试另一种方法工作

Under the EnableDeprecatedWebPlatformFeatures key create a string value with name 1 and value of ShowModalDialog_EffectiveUntil20150430. To verify that the policy is enabled, visit chrome://policy URL.


UPDATE: If the above didn’t work for you here’s another method to try.


  1. 从<一个下载Chrome ADM模板href=\"http://www.chromium.org/administrators/policy-templates\">http://www.chromium.org/administrators/policy-templates

  2. 提取及相关的语言环境(如Windows \\ ADM \\ EN-US \\ chrome.adm。您可以导入或者通过输入gpedit.msc 或使用这些工具的进口政策在Windows家庭版:<一href=\"http://blogs.technet.com/b/fdcc/archive/2008/05/07/lgpo-utilities.aspx\">http://blogs.technet.com/b/fdcc/archive/2008/05/07/lgpo-utilities.aspx)

  3. 在管理模板,找到谷歌浏览器模板,并启用启用德precated Web平台Feautes。

  4. 打开该功能,并添加ShowModalDialog_EffectiveUntil20150430键。

  1. Download Chrome ADM templates from http://www.chromium.org/administrators/policy-templates
  2. Extract and import policy relevant to your locale (e.g. windows\adm\en-US\chrome.adm. You can import either via gpedit.mscor using these utilities on Home editions of windows: http://blogs.technet.com/b/fdcc/archive/2008/05/07/lgpo-utilities.aspx)
  3. Under "Adminstrative Templates" locate Google Chrome template and enable "Enable Deprecated Web Platform Feautes".
  4. Open the feature and add "ShowModalDialog_EffectiveUntil20150430″ key.

这篇关于我怎样才能让在Chrome 37 window.showmodaldialog工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆