-2

I have an iframe generated by Power BI. I am not able to change the font size.

I have tried targeting it by span and div but in vain.

    <script>
 var span = document.getElementById("myFrame");
span.style.fontSize = "100px";

        </script>

    <iframe span id="myFrame"  width="500" height="150" src="https://app.powerbi.com/view?r=eyJrIjoiNjBlM2EyMWUtMmU1My00NzkyLWE1NTgtNDYyZDUzZTg5YmM3IiwidCI6IjNiZDI3ZWY4LThkMzgtNDY1Ni04NmQyLTVmMGQ5MGE3Mzk4MSIsImMiOjN9" frameborder="0" allowFullScreen="true"></iframe>

Have also tried this

<script>
function changeSize(){
    var frame = document.getElementById("myFrame");
    var content = (frame.contentDocument || frame.contentWindow);
    content.body.style.fontSize = "200%";
}

changeSize();
 </script>

The iframe displays a number. And I would like to Increase the font-size of that number using JavaScript. So far I have no luck. Any help on this matter would be greatly appreciated.

user3402248
  • 439
  • 6
  • 25
  • 1
    I think the iframe url has to be on the same domain that the parent window/tab uses – Keagz93 Oct 16 '17 at 08:29
  • 1
    You have no JavaScript access to content inside an iframe that is loaded from a different domain; that's called Same Origin Policy. – CBroe Oct 16 '17 at 08:31
  • You should be getting error messages on the Console in your browser's developer tools. Reading them and using them as the basis for a web search would have saved you from having to ask this question. – Quentin Oct 16 '17 at 08:43

1 Answers1

-3

why does your <iframe> has 'span' in it?

write it like this:

<iframe id="myFrame"  width="500" height="150" src="https://app.powerbi.com/view?r=eyJrIjoiNjBlM2EyMWUtMmU1My00NzkyLWE1NTgtNDYyZDUzZTg5YmM3IiwidCI6IjNiZDI3ZWY4LThkMzgtNDY1Ni04NmQyLTVmMGQ5MGE3Mzk4MSIsImMiOjN9" frameborder="0" allowFullScreen="true"></iframe>

now you can use your js like you used before :

var span = document.getElementById("myFrame");
span.style.fontSize = "200%";

or

var span = document.getElementById("myFrame");
span.style.fontSize = "xx-large";
shikhar
  • 174
  • 1
  • 11