Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7879473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:54:17+00:00 2026-06-03T03:54:17+00:00

I am trying to stop a file from uploading when the user clicks on

  • 0

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:

$('.upload_target').contentWindow is undefined

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?

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;

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

Below is the form code which consists of the iframe:

 var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='return startImageUpload(this);' class='imageuploadform' >" + 
    "Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><br/><label class='imagelbl'>" + 
    "<input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /></label>" + 
    "</p><p class='imagef1_cancel' align='center'><label>" + 
    "<input type='button' name='imageCancel' class='imageCancel' value='Cancel' /></label></p>" + 
    "<iframe class='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px;solid;#fff;'></iframe></form>"); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:54:17+00:00Added an answer on June 3, 2026 at 3:54 am

    $('.upload_target') will return a jQuery object containing all elements with that class, so the contentWindow property wont exists

    $(.upload_target:eq(0)').get() will return the (first but assuming only one) element itself and then contentWindow should exists

    or $(.upload_target')[0] if you are targetting a single element but then an ID would be more performant

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to stop my form from submitting yet I never can get
I'm trying to stop the browser from following certain links, rather I want to
I am trying to generate a CSV file from DB Query as source one
I am trying to read some objects from a file. The code works fine
I am trying to retrieve particular data from a txt file and would like
I am trying to extract some data from URLs in a LOG file and
I'm trying to extract a string from a text file using 2 delimiters. One
I'm trying to get a value from a variable inside some files, here is
What I'm trying to do is fairly simple: send a file from client to
I am trying to read in from a file that contains city names, an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.