2

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!

Dave
  • 1,257
  • 2
  • 27
  • 58

2 Answers2

2

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.

tao
  • 82,996
  • 16
  • 114
  • 150
2

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.

Rajshekar Reddy
  • 18,647
  • 3
  • 40
  • 59
  • so if it is the same domain, I can just style it like I normally would? – Dave Oct 22 '16 at 06:09
  • Yes .. it should be straight forward – Rajshekar Reddy Oct 22 '16 at 06:46
  • Please note you still need access to the iframe contents. You need to set the `domain` on both parent and child: `document.domain = "yourdomain";`. This has to be done in document loading phase. After this you can access your iframe document via javascript from the parent (so you can add stylesheets to it from parent). – tao Oct 22 '16 at 11:34