Several questions about using jQuery to create name in iframe

Source: Internet
Author: User

Nima found out when I was doing Upload. js last time. Because I didn't take notes, I still moved on to this issue for 15 minutes today... Mom...
The cause is to use iframe + form for the upload function, and create a form> input to insert it into the body. (ps: it is best not to insert it next to the dom of your upload button, because form may appear in the form, and then ...), Let the input [type = file] element be very large, and then make the width and heigth of the form consistent with that of the upload button. Then locate the problem...
Then create an iframe...
So there is a pitfall...
Because there may be multiple such instances on the page, you need to use guid to mark each instance, because now you need to submit the form to iframe when submitting the form, to simulate the great ajax... the target on form must be the same as the name of iframe... Don't ask why... Originally created in this way:

The code is as follows: Copy code

$ Iframe = $ ('<iframe/>'). attr ({
Id: key + '_ iframe ',
Name: key
}). AppendTo ($ body );

However, I found that IE7 is invalid. The name generated for me is not named name... As shown in the following figure:

In this way, a new window is always opened during submission... So we need to change the code for creating iframe...

The code is as follows: Copy code

$ Iframe = $ ('<iframe id = "' + key + '_ iframe" name = "' + key + '" class = "ui-upload-iframe"> </ iframe> '). appendTo ($ body );

Then solve the bug...

In this way, when a user clicks, it is equal to the input [type = file] of the direct vertex. Then, when you bind Chang'e (change), submit it to iframe... and resolve the contents (). body () in iframe...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.