Using iframe to submit a form, how do I return the value to the previous layer?

Source: Internet
Author: User
1. How to transfer the information in iframe to div? 2. If div is used without iframe, how can we make the form in the div submit without redirecting? 3. After a file is submitted to the server, how does one obtain its address and return it to the input file? {Code...} upload. php: {code...} 1. How to transmit the information in iframe to p?
2. if I use p instead of iframe, how can I submit the form in p without redirecting?
3. After a file is submitted to the server, how does one obtain its address and return it to the input file?

    

Upload. php:

Script // upload image function uploadImg () {$ ("form: first"). trigger ("submit")} script

Reply content:

1. How to transmit the information in iframe to p?
2. if I use p instead of iframe, how can I submit the form in p without redirecting?
3. After a file is submitted to the server, how does one obtain its address and return it to the input file?

    

Upload. php:

Script // upload image function uploadImg () {$ ("form: first"). trigger ("submit")} script

upload.phpAfter saving the file, return the following path to the upper layer.


  Script parent. $ ('input'). val ("
  "); Script

Simply putparentThen you can accessiframeThe content in the page.

Online Demo address: https://xqin.net/temp/up.html

up.phpThe Code is as follows (this is only a demonstration, so only the current time is output ):


  Response scriptaskparent.doc ument. getElementById ('result'). value ="
  "; Script uploaded!
  

I encountered iframe and external communication when I was working on the chrome plug-in. I don't know if it is helpful.

Https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

Https://github.com/xwartz/xwartz.github.com/issues/1

H5web communication, http://www.cnblogs.com/ATree/archive/2012/03/07/html5-web-messaging.html

After the iframe is successfully renewed, the value is redirected to the iframe.

Event upload to window. onload, and then get data in iframe.

The window object in iframe can not be obtained externally. Get a function externally, block the default event when submitting the object in iframe, and then call the external callback.

Asynchronous form submission is not enough.

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.