Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to correctly stop the transport inside 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 here: </p> <pre><code>$('.upload_target').contentWindow is undefined </code></pre> <p>How can this first of all be 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 transpart 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').get(0).contentwindow if ($('.upload_target').contentWindow.document.execCommand) { // IE browsers $('.upload_target').contentWindow.document.execCommand('Stop'); } else { // other browsers $('.upload_target').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.
 

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