Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to fix this error dealing with an iframe
    primarykey
    data
    text
    <p>I am trying to stop a file from uploading when the user clicks on the "Cancel" button. To do this I am thinking of stopping the transport inside the iframe. The problem is be able to code this correctly. Below is the code of what I am trying to achieve but I am getting this error when I click on the "Cancel" button: </p> <pre><code>Uncaught exception: [Exception.... “Not enough arguments [nslDOMHTML.Document.execCommand]” nresult: “0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)” location: “JS frame;; https://......../QandATable.php = &lt;TOP_LEVEL&gt; ;; line 765” data: no] </code></pre> <p>First of all how can this error be fixed and second how can the code below be written correctly so that when the "Cancel" button is clicked on, it stops the transport inside the iframe?</p> <p>Below is the startImageUpload() function where it starts uploading a file. Within that function is the function which handles the "Cancel" button when it is clicked;</p> <pre><code>function startImageUpload(imageuploadform){ $(".imageCancel").click(function() { $('.upload_target')[0].contentwindow if ($('.upload_target')[0].contentWindow.document.execCommand) { // IE browsers $('.upload_target')[0].contentWindow.document.execCommand('Stop'); } else { // other browsers $('.upload_target')[0].contentWindow.stop(); } return stopImageUpload(); }); return true; } </code></pre> <p>Below is the form code which consists of the iframe:</p> <pre><code> var $fileImage = $("&lt;form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='return startImageUpload(this);' class='imageuploadform' &gt;" + "Image File: &lt;input name='fileImage' type='file' class='fileImage' /&gt;&lt;/label&gt;&lt;br/&gt;&lt;br/&gt;&lt;label class='imagelbl'&gt;" + "&lt;input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /&gt;&lt;/label&gt;" + "&lt;/p&gt;&lt;p class='imagef1_cancel' align='center'&gt;&lt;label&gt;" + "&lt;input type='button' name='imageCancel' class='imageCancel' value='Cancel' /&gt;&lt;/label&gt;&lt;/p&gt;" + "&lt;iframe class='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px;solid;#fff;'&gt;&lt;/iframe&gt;&lt;/form&gt;"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload