I have to access a URL that generates plain text with the content that I need.
The project is done with Web Traditional. I am using the IFRAME component to access the website. I can access the site and show the text.
The site only displays 1 line with this return text.
However, how can I set the text to a variable or manipulate the text as a string within Outsystems?
For example, to give a MessageBox with the content or insert it into the database.
Note: I made the site using PHP with Javascript. And I return an html page with a return string.
Thanks.
I would like to thank everyone who helped me. The shared knowledge will be useful in any way.
Special thanks to Carlos López Santibáñez Jácome. He was the first one who understood better what I needed and recommended me to use GetRequest_Submit from HTTPHandler extension, instead of trying via IFRAME. And also indicated not to call HTML that calls PHP. I switched to a direct call to PHP. It works. It is still a little slow, but the desired result has been achieved.
Paulo Jadaugy and Jorge Martins, my thanks to you! I wish you all the best!
I forgot to put the reference of the person who solved the problem: Carlos López Santibáñez Jácome
Hi Fabricio,
Assuming your iFrame is in the same domain as your OutSystems application you can run Javascript to get the values:
var myIFrame = document.getElementById('<Widget.Id>'); //Fetch Inner HTML inside body var contentHTML = myIFrame.contentWindow.document.body.innerHTML; //Fetch Inner Text inside body var contentText = myIFrame.contentWindow.document.body.innerText;
var myIFrame = document.getElementById('<Widget.Id>');
//Fetch Inner HTML inside body var contentHTML = myIFrame.contentWindow.document.body.innerHTML;
//Fetch Inner Text inside body
inside body
var contentText = myIFrame.contentWindow.document.body.innerText;
Since it's traditional you can have an input hidden and change the value via Javascript and then use it in OutSystems.
If the iframe is not in the same domain you can face some Same Origin Policy issues.
Hope it helps.
Regards,Paulo Jadaugy
My Iframe calls an HTML file that calls a PHP file that calls a JAVASCRIPT file that returns content from an external URL and I have to manipulate the returned string. When I try to use: "alert (document.getElementsByClassName ('OSInline'). Document.body.innerText);"
There is a refresh in the IFRAME and it doesn't give me an alert with the content I need.
If the PHP file is from same domain, the previous Javascript should work passing the iframe element to get the content inside the iframe.
Have you tried that Javascript to get the content, you can even debug in the console of the browser first to see if it works.
I'm doing tests, so the domain is at Outsystems (some.outsystemscloud.com/etc). And the php file is in a domain that I have. Should I add PHP to the project? How to do this?
If possible it should be easier to implement the logic from the PHP page to an OutSystems page and then you would be able to do what you need without changing domains.
Otherwise you need 2 servers (one for OutSystems and one for you PHP page) inside your domain and the script should work fine, just did a quick test with the page you sent.
Example: