无法从外部函数关闭 Simplemodal

发布于 2024-11-07 08:01:30 字数 1258 浏览 0 评论 0原文

所以我创建了一个简单模式框,里面有一个 iframe。在 iframe 中,我有一个文本框,一旦提交,它就会调用一个函数。然后该函数关闭并执行它自己的命令。我想做的是在人们提交文本后关闭简单模式框。我还没有真正看到允许我为模式设置 id 的属性,以便我可以在函数外部引用它。这是我的代码:

模式:

$.modal('<iframe src="chrome-extension://kdcfmjjkjcgaklpmpnhcmieepkiddfen/options.min.html" height="120" width="300" style="border:0">', {
                close: true,
                closeHTML:"",
                containerCss:{
                    backgroundColor:"#000",
                    borderColor:"#000",
                    height:100,
                    padding:0,
                    width:300,
                    height:125
                },
                overlayClose:true,
                opacity:50,
                overlayCss: {backgroundColor:"#000"}
            });

options.min.html:

passMessage:

function passMessage() {
        var value = document.getElementById('speechInput').value;
        var event = "commands"
        $.modal.close();
        chrome.extension.sendRequest({command:value}, function(response) {});
    }

如您所见,模态使用 options.min.html 在模态内创建语音输入框。一旦用户停止说话,就会调用另一个函数,从该框中获取值。然而 $.modal.close();函数实际上并没有关闭模态,而是只是挂起我的程序并且它无处可去。我需要知道如何引用其他地方创建的模式。

感谢您的帮助

So I create a simplemodal box with an iframe inside of it. in the iframe I have a text box which calls a function once it is submitted. This function then goes off and executes its own commands. What I want to do is after the person submits their text for the simplemodal box to close. I haven't really seen a attribute that allows me to set an id for the modal so I can refer to it outside the function. Here is my code:

the modal:

$.modal('<iframe src="chrome-extension://kdcfmjjkjcgaklpmpnhcmieepkiddfen/options.min.html" height="120" width="300" style="border:0">', {
                close: true,
                closeHTML:"",
                containerCss:{
                    backgroundColor:"#000",
                    borderColor:"#000",
                    height:100,
                    padding:0,
                    width:300,
                    height:125
                },
                overlayClose:true,
                opacity:50,
                overlayCss: {backgroundColor:"#000"}
            });

the options.min.html:

the passMessage:

function passMessage() {
        var value = document.getElementById('speechInput').value;
        var event = "commands"
        $.modal.close();
        chrome.extension.sendRequest({command:value}, function(response) {});
    }

as you can see the modal uses the options.min.html to create a speech input box inside the modal. Once the user stops talking another function is called in which the value is taken from that box. However the $.modal.close(); function does not actually close the modal but instead just hangs my program and it goes nowhere. I need to know how to refer to the modal that is created elsewhere.

thanks for any help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↘紸啶 2024-11-14 08:01:30

如果您想从 iframe 中关闭模式,请使用以下 JavaScript:

parent.$.modal.close();

至于 ID,SimpleModal 会自动将它们添加到对话框元素中:simplemodal-overlaysimplemodal-containersimplemodal-data

If you want to close the modal from within the iframe, use the following JavaScript:

parent.$.modal.close();

As for ID's, SimpleModal automatically adds them to the dialog elements: simplemodal-overlay, simplemodal-container, and simplemodal-data

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文