JavaScript - New File() not working
<p>I am trying to write some strings to a file using JavaScript through the following code   </p>

<pre><code>var txtfile ="../wp-content/plugins/MedicAdvisor/test.txt";
    var file = new File("hello",txtfile);
    //file = fopen("", 3);// opens the file for writing
    file.open("w");

    var currentrow = 0;
    var nextrow = 0;
    var type = " ";
    var noofrows = 0;
    var noofcells = 0;
    var contentarray;
    var row = document.getElementsByTagName('tr');
    //get all elements having input tag
    var inp = document.getElementsByTagName('input');
    // traverse through all input tags
    for (var i=2; i&lt;inp.length; i++){
        // see if it is a heckbox
        if(inp[i].type == "checkbox"){
            // see if it is checked
            if(inp[i].checked == true){
                //index of current row
                currentrow = inp[i].parentNode.parentNode.rowIndex;
                //event type
                type = inp[i].parentNode.parentNode.cells[6].innerHTML.trim();
                if (type == "cycling_road_race"){
                    noofrows = 6;

                    for(var j=0; j&lt;noofrows; j++){
                        noofcells = row[currentrow + j + 1].cells.length;
                        for (var k=1; k&lt;noofcells; k++){
                            //alert (row[currentrow + j + 1].cells[k].innerHTML.replace('&lt;br&gt;' , ' '));
                            contentarray.push(row[currentrow + j + 1].cells[k].innerHTML.replace('&lt;br&gt;' , ' '));
                            file.writeln(row[currentrow + j + 1].cells[k].innerHTML.replace('&lt;br&gt;' , ' '));
                        }
                    }
                }
                else if (type == "cycling_criterium_or_circuit_race"){
                    noofrows = 6;
                }else if (type == "cycling_cyclocross"){
                    noofrows = 6;
                }else if (type == "running_race"){
                    noofrows = 6;
                }else if (type == "rugby_football_hockey"){
                    noofrows = 6;
                }else if (type == "music_festival"){
                    noofrows = 6;
                }else if (type == "manual_selection"){
                    noofrows = 5;
                }
            }
        }
    }
</code></pre>

<p>but I am getting following error when I try to execute this code</p>

<blockquote>
  <p>Failed to construct 'File': The 1st argument is neither an array, nor
  does it have indexed properties</p>
</blockquote>

<p>Kindly help me resolve this issue</p>