无法从外部函数关闭 Simplemodal
所以我创建了一个简单模式框,里面有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想从 iframe 中关闭模式,请使用以下 JavaScript:
至于 ID,SimpleModal 会自动将它们添加到对话框元素中:
simplemodal-overlay
、simplemodal-container
和simplemodal-data
If you want to close the modal from within the iframe, use the following JavaScript:
As for ID's, SimpleModal automatically adds them to the dialog elements:
simplemodal-overlay
,simplemodal-container
, andsimplemodal-data