首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >火狐中的showModalDialog

火狐中的showModalDialog
EN

Stack Overflow用户
提问于 2016-10-16 17:32:55
回答 1查看 1.6K关注 0票数 0

有没有可能将此Chrome插件转换为在Firefox中工作?

https://github.com/chuckhendo/showModalDialog-shim

该插件需要用window.open替换window.showModalDialog

代码语言:javascript
复制
'use strict';

var shim = '(' + function() {
if(typeof window.showModalDialog !== 'function') {
    window.showModalDialog = function() {
        var opts = arguments[2];
        opts = opts
            .replace(/;/g, ',')
            .replace(/:/g, '=')
            .replace(/dialogWidth/g, 'width')
            .replace(/dialogHeight/g, 'height')
            .replace(/center/g, 'centerScreen');
        return window.open.call(this, arguments[0], '_blank', opts );
    };
}
} + ')();';

var scriptEl = document.createElement('script');
scriptEl.textContent = shim;
(document.head||document.documentElement).appendChild(scriptEl);
EN

回答 1

Stack Overflow用户

发布于 2016-11-02 13:53:57

您可以在GreaseMonkey中运行此命令。安装GreaseMonkey扩展,然后将上面的代码添加为用户脚本。

下面是为GreaseMoney重写的代码:

代码语言:javascript
复制
// ==UserScript==
// @name        AddShowModal
// @namespace   http://www.weirdies.net
// @version     1
// @grant       none
// @include     *
// ==/UserScript==

(function () {
    var shim = '(' + function() {
    if(typeof window.showModalDialog !== 'function') {
       window.showModalDialog = function() {
        var opts = arguments[2];
        opts = opts
        .replace(/;/g, ',')
        .replace(/:/g, '=')
        .replace(/dialogWidth/g, 'width')
        .replace(/dialogHeight/g, 'height')
        .replace(/center/g, 'centerScreen');
    return window.open.call(this, arguments[0], '_blank', opts );
   };
}
} + ')();';



var scriptEl = document.createElement('script');
scriptEl.textContent = shim;
(document.head||document.documentElement).appendChild(scriptEl);
})();

我确认它可以与OWA10一起工作,可以弹出附加对话框等,而不必将dom.disable_window_showModalDialog设置为false并禁用电泳。它看起来有点笨拙,而且似乎不能正确地转换宽度和高度(它会全屏打开,我现在没有时间调试它),但它可以工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40068839

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档