Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send parameter to Iframe with a HTTP POST request

I have to send some parameter to an IFRAME with POST method. I have read here Setting the HTTP request type of an <iframe> that it isn't possible. I'm thinking a solution in Javascript but I can't implement it so I can't test if it is a valid solution for this issue. I want to ask if someone has the same problem and if it is possible to solve and in positive case how to?

like image 983
jRicca Avatar asked Jul 18 '11 08:07

jRicca


People also ask

Can you pass parameters to an iframe?

You can use a script to get the desired parameter value from parameters passed to page. Show activity on this post. If you have slightly more control on your iframe sandbox, you can try postMessage API to communicate with message on events you desire to trigger.

Is iframe get or post?

No. The URL specified by the src attribute is used to make a GET request. You can get the results of a POST request to display in an iframe, but that requires that you submit a form with target="name_of_iframe" and not just use the src attribute.

Can you post to an iframe?

Doesn't take any JavaScript or anything. You just have the form's target attribute match the iframe's name attribute. The outer page doesn't even reload.

How do you send parameters to the post method?

In a GET request, the parameters are sent as part of the URL. In a POST request, the parameters are sent as a body of the request, after the headers. To do a POST with HttpURLConnection, you need to write the parameters to the connection after you have opened the connection.


2 Answers

<form ... target="hidden_iframe"> ... </form>  <iframe name="hidden_iframe" ...></iframe> 
like image 147
Walialu Avatar answered Sep 20 '22 08:09

Walialu


How about using the target attribute of the form to point to iFrame?

 <form target="myIframe" action="http://localhost/post.php" method="post">     <input type="hidden" value="someval" />     <input type="submit"> </form>  <iFrame src="" name="myIframe"></iFrame> 
like image 37
KishoreK Avatar answered Sep 19 '22 08:09

KishoreK