Error when submit form to iframe

Hi,

I am with a problem when I submit a form html to iframe OutSystems. The screem dont show of the app web.

How I do this correctly?


I put on my html form in expression field:

keep hrml form...

After that process above, I define a iframe component to receive url target.


The execution to show iframe, happen when the user click on button in the screen, but not happening.


What's the problem?



Hi Bernardo.

Instead of using an expression with your <html> document (which will be injected inside another <html> document), I recommend you to use a Download at the end of the preparation to download your <html> without having any interference from the platform.

You will need to convert it to binary before downloading. That can be done with the TextToBinaryData action from the BinaryData extension.

Hi leonardo.fernandes.

Sorry, I didn't understand your solution, because, I have other application (java, jsp) and I need simply put in iframe OutSystems. In my project, I need send a form html to that application. Imagine the situation who you need put in this site https://www.google.com.br like a iframe inside your site Outsystems, and thus, that site to function need that data form. One information very important: That form need send with Post method HTTP.


Thanks.

Bernardo, the way you're injecting the HTML into OutSystems, by using an unescaped expression, is not correct. Unescaped expressions were meant to inject HTML fragments into the body, and you're using them to inject an entire HTML document. Your document will be nested into the body of a different document, which is something browsers prohibit, and one of their options is to ignore some parts of your document to avoid having nested documents.

Here's an example. This is the (simplified) HTML that is written by the platform (you can't change this easily):

<html>
<body>
<form method="POST" action="WebScreen.aspx">
<!-- All widgets on a screen will be rendered in here, inside the page-level <form> -->
</form>
</body>
</html>


If you insert an HTML with a "hello world" form in an unescaped expression, this is the HTML you will get:

<html>
<body>
<form method="POST" action="WebScreen.aspx">
    <html>
    <body>
        <form method="POST" action="urlDestino">
        ...
        </form>
    </body>
    </html>
</form>
</body>
</html>


You can start to see a few problems in there. First, <html> needs to be the topmost tag, so browsers will ignore your nested <html> tag. A similar rule applies to <body>, which will also be ignored. Lastly, you cannot have nested <form> tags, so the browser will ignore your <form> tag, and leave the platform's <form> tag.


How to prevent this from happening? Do not use unescaped expressions, if you want to output an entire HTML document. Instead, use a Download node, and just download to the browser your HTML document, converted to binary data (see my first comment), and remember to use the content type "text/html".

Another information that might be important to your use case (from your example of including google inside of an iframe, you could to be trying to include an iframe from a different domain).

Most web sites now adopt the X-Frame-Options header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options) which prevents browsers from embeding the website in frames from a different domain. This is a technique employed to prevent clickjacking, and is a recommended security practice. In this case, it won't be possible to embed such a website into an iframe.

Hi Bernardo, As Leonardo says, you have to link the iframe to another domain otherwise you need to convert the files to a binary format to upload it into the server. also needs to use proper HTML for it to do. so no nested Html or body tag will not be there. I hope this will help you.

Fellas, sorry.


My project in the OutSystems and another web app are the same domain, so I need put that webapp inside in my body HTML OutSystems via iframe, is just it. But I need also send a form HTML via method POST to that iframe.


One information very important: I have some web apps with same situation. I only put webapp (URL) in iframe and send form HTML via method GET or without form HTML, all with successful.


That my problem is just when I send form via method POST.

Hi Bernardo. I still don't understand what you're trying to accomplish. Let me see if I got this right: you have an OutSystems web application as your main document, and inside of this document you have an iframe with another web application, not developed in OutSystems, but within the same domain. Is this correct?


Then you have a form... is it in the OutSystems application, or in the application that's on the iframe? What is the action of the form? Is it an action of the OutSystems application, or an action of the application that's on the iframe?

And you want to send the form via POST to the iframe. Does that mean that you want to display the result of the POST inside the iframe?