简体   繁体   中英

Apply css style to iframe page before it loads

I have a page that loads an iFrame. I would like to apply a style to the iframe from the top page.

Following code works. But it applies on frame refresh. How can I make it apply before the iframe loads. Because for a second the item I'm setting display to none shows then goes away.

I tried window.onload which did not work at all. The onload event gets called but the style does not set.

No I can not put the style inside the iFrame page directly. It's out of my control.

<script type="text/javascript">
    function onFrameRefreshed() {
        frames['testIframe'].document.getElementById("bannerDiv").style.display="none";
    }
</script>

<div>
    <iframe name="testIframe" ID="testIframe" src="https://someframepage.mycompany.com" width="100%"
        height="1000px" onload="onFrameRefreshed()" frameborder="0">No iframe support </iframe>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM