0

I tried finding an attribute to include GET and POST inside the IFRAME, but couldnt find any.

<iframe src="/default.asp" method="POST">
  <p>Hello IFRAMES</p>
</iframe>

I tried the above but it didn't help. Why dont have method attribute inside IFRAME to include GET and POST. My default it is GET i guess, i want it to be POST.

  • 1
    Can this be helpfull? https://stackoverflow.com/questions/6730522/how-to-send-parameter-to-iframe-with-a-http-post-request And can you write what is you usecase? – jare25 Mar 23 '21 at 09:08

1 Answers1

0

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.

It's possible to hack this by submitting such a form with JS on page load.

That said, POST requests are designed for sending a request to change/add data on the server. They aren't generally useful unless the user is entering data into a form. Thus triggering a POST request as a soon as a page loads doesn't usually make any sense. You should probably be reevaluating the desire for a POST request here in the first place.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • The desire to use POST is for hiding the parameters passed through the URL. – Nithin kulkarni Mar 23 '21 at 09:19
  • 1
    @Nithinkulkarni — If you used POST then they would still be visible in the browser's developer tools Network tab. You cannot ask the user's browser to send you data and keep it a secret (well, unless it is encrypted before it is even sent to the browser in the first place and remains encrypted until it gets back to the server). – Quentin Mar 23 '21 at 09:20