1

I am creating a web application called List Maker in JavaScript, and one of the functions is to be able to export / import data from JSON. For exporting and importing JSON data, a popup will be displayed allowing the user to copy / enter data.

However, I am having trouble showing the popup, as I keep getting this error:

[Exception... "The operation is insecure."  code: "18" nsresult: "0x80530012 (SecurityError)"  location: "<unknown>"]

Here's the function that displays the popup:

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();
}

And the exporttojson div:

<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>

The code for the GetJSONFromList() function:

function GetJSONFromList()
{
    return JSON.stringify(LMList);
}
Igor
  • 548
  • 3
  • 7
  • 24
  • What is the code for your GetJSONFromList() function? The error likely comes from there. – Nzall Jul 14 '14 at 12:54
  • Could you place a breakpoint on your window.open(), then step through the code and tell us what line you get that error? also, gpgekko has the solution. – Nzall Jul 14 '14 at 13:02

1 Answers1

0

Should it be like this?

function GetJSONFromList(LMList)
{
    return JSON.stringify(LMList);
}
peterpeterson
  • 1,315
  • 2
  • 14
  • 38
  • Sorry for the confusion, but LMList has already been defined elsewhere and is accessible. – Igor Jul 14 '14 at 20:53