Dave
Dave

Reputation: 1277

Is it possible to style an iFrame

I'm working in ServiceNow and have created a simple donut chart using Reports basically showing percentage of tasks completed. I want to pull this into my portal page's dynamic block and style it (i.e. mess around with the sizing, give it a background color). Is this possible? I know I can pull the report in via iFrame, but is there any flexibility there in terms of formatting?

Thanks!

Upvotes: 2

Views: 492

Answers (2)

Rajshekar Reddy
Rajshekar Reddy

Reputation: 18997

One and only rule to be able to style your iframe or have any way of control over it is

Your webpage and the iframe both have to be under same domain

Else there is no way you can do it. The browser restricts you from doing so. Its a security standard followed by all the browser's.

Upvotes: 2

tao
tao

Reputation: 90138

In order to style an iframe, you will need to have access to whatever is generating it, just like with any other web document.

An iframe is a different (child) document loading inside a designated area of your parent one.

Mainly as a precaution against cross-frame scripting, communication between the iframe and the parent is disabled by default but can be enabled if the child document allows it. With this communication closed, responsiveness becomes a major issue.

Note it is possible for a page to check if it is rendered inside an iframe and forbid it (refuse to render) or display a nasty custom message informing the visitor it doesn't belong there.

Also, please note iframes should be avoided for accessibility reasons, as many handheld devices display them awkwardly and some don't display the iframe contents at all.

Upvotes: 2

Related Questions