JavaScript 弹出窗口"The Action Is Insecure"



我正在JavaScript中创建一个名为List Maker的web应用程序,其中一个功能是能够从JSON导出/导入数据。对于导出和导入JSON数据,将显示一个弹出窗口,允许用户复制/输入数据。

然而,我有麻烦显示弹出,因为我不断得到这个错误:

[Exception... "The operation is insecure."  code: "18" nsresult: "0x80530012 (SecurityError)"  location: "<unknown>"]
下面是显示弹出窗口的函数:
function JLShowExportDialog()
{
    var w = window.open('', '', 'width=400,height=400,scrollbars');
    w.document.write(document.getElementById("exporttojson").innerHTML);
    w.document.body.style.fontFamily = "sans-serif";
    w.document.getElementById("jsontext").innerHTML = GetJSONFromList();
    w.document.title = "Export List To JSON";
    w.document.close();
}

exporttojsondiv:

<div id="exporttojson" style="display: none">
    <h1>Export to JSON</h1>
    <p>The text in the box below contains the JSON.</p>
    <textarea id="jsontext">
    </textarea>
</div>

GetJSONFromList()函数代码:

function GetJSONFromList()
{
    return JSON.stringify(LMList);
}

应该是这样吗?

function GetJSONFromList(LMList)
{
    return JSON.stringify(LMList);
}

相关内容

最新更新