JS CODE to display in Iframe a link recorded in a field

Hi Guys,

I have a URL Link field in an object and I would like to display its content using a richtext with iframe code on it.

As the url link is connected to each record, it will change acoording to the connected record in an objet.

I would like to know if someone have a code sample to help me make it work.

Thanks!

Hi @Guilherme

The easiest way to do this is with a text formula such as:

<iframe src="{Link}" width="800" height="500"></iframe>

Where {Link} is your link field with the URL.

You can then simply add this to any details view.

Julian

Hi @JulianKirkness,

Thanks for you response, but the link will be dynamic and connected to the record’s page. So for each record, the link will be different.

Any thoughts?

Create a text formula field in the object.
Copy the code and paste it into the text formula.

Wherever you see the link, just replace that with url field inside where you pasted the code.

I hope this helps.

Thank you

Hi @Guilherme

As above , my suggestion was to set up a text formula field with the html shown in my last post. This will render the associated web pager (from the {Link} field) in the iframe when the field is displayed.

Julian

Hi @JulianKirkness and @Godfred,

I tried both. The text formula with the iframe code is prohibited by knack security system, which will not render the external url content.

The richtext code <iframe src="{field_4071}" width="800" height="500"></iframe> is resulting in an error:

"# Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

I set richtext to condution rules and set the code to populate this richtext for each record, but I’m not getting the page content in the iframe.

Any thoughts?

Hi @Guilherme

In my test database, the <iframe> approach works - as <iframe> is a whitelisted html tag. Here is a screenshot of the field setting and a page displaying it:

HOWEVER, I have discovered that it will only display an https site so this could be your issue?

Julian

Hello Guil,

You added the field id instead of the field name.

Regards,
Sunny Singla

Hi All,

I was able to make it work with text formula. The issue is that a document on word online is not allowed to display in an iframe if its not public. That’s why it was not working…

The iframe method works well, thanks for sharing @JulianKirkness - I hadn’t come across it before. I have been using the Google drive embed version for some years and thought others may find it of interest. :+1: