Focal Point
[CLOSED] Loading Dynamic Webfocus HTML Content into IFrame from Control

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3587061786

July 07, 2017, 11:42 AM
SAI_Ryan
[CLOSED] Loading Dynamic Webfocus HTML Content into IFrame from Control
I have an HTML drop down control being dynamically populated from an XML fex file. The display value is the report name and the actual value is a fex url. This part is working fine.

What i am trying to do is when I click on a selection that URL is loaded into the Iframe in my html page. Does anyone know how to accomplish this?

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8
Windows, All Outputs
July 07, 2017, 04:12 PM
mlhapner
Hi Ryan,

I would just create another fex file and use an HTMLFORM to display the variable, like so:

-HTMLFORM BEGIN
&URL
-HTMLFORM END

This fex would be placed in the desired panel.

You also will need to add some javascript to refresh the panel displaying the URL on change of the drop down value. I can post some code if needed for that.

Matt


WebFOCUS 8.201m
Windows, All Outputs
July 07, 2017, 04:53 PM
SAI_Ryan
When trying this method I just get an html page with the link displayed. I want to actually display the content of the link inside of the frame.


WebFOCUS 8
Windows, All Outputs
July 10, 2017, 09:08 AM
mlhapner
Ah. You cannot force an iframe to display another website if it has a different source than the website you're currently on. That would violate all sorts of security features. However, if the URL is of the same source you could use some basic javascript to load it:

quote:
-HTMLFORM BEGIN
<script>
window.location.href = "&URL"
(end script tag here)
-HTMLFORM END


If you are trying to load a URL of a different source I would suggest having it open in a new tab after click of a button or change of a drop down value.


WebFOCUS 8.201m
Windows, All Outputs
July 10, 2017, 10:50 AM
SAI_Ryan
Thanks I will try that. I was testing the functionality using google and other things which was likely my problem since it worked when forced a new window but no when I loaded onto current page.

Can I bring it into the iframe if it is the company domain but not webfocus? We have some legacy reports that aren't housed in WF but are still located on mycomany.com domain.

You also mentioned some javascript to refresh the frame I would be very interested in that if you could share. I appreciate the help!


WebFOCUS 8
Windows, All Outputs
July 10, 2017, 11:10 AM
dhagen
Sounds like a CORS request. If so, you may need 8201M and you will have to configure the Cross-Origin Settings in your default security zone.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
July 10, 2017, 11:11 AM
mlhapner
I believe it is possible to grant iframe permission on a webpage. It has something to do with X-Frame-Options. Take a look here. The javascript error I receive when trying to view google in a iframe is
quote:
Refused to display 'https://www.google.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

It looks like you just need to change the X-Frame-Options setting in your webpage (mycompany.com) to ALLOW-FROM wherever your request is being made from.

Also, here is some starter code that will help you refresh panels on change of a drop down value:

quote:
function refreshReports() {
var name = this.window.name;
var iframeArray = ["Tab_0_1"];
parent.BipIframeInterface.setAllAmpersValues(name, IbComposer_getAllAmpersValues());
parent.BipIframeInterface.refresh(parent.BipIframeInterface.REFRESH_ARRAY, name, iframeArray);
}


Let me know if you have further questions,

Matt


WebFOCUS 8.201m
Windows, All Outputs
July 10, 2017, 11:35 AM
dhagen
quote:
Originally posted by mlhapner:
Refused to display 'https://www.google.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.


That is a HTTP response header that is part of a CORS pre-flight response. It has to be addressed from the web app side of things.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott