2017-02-27 110 views
0

我有一個iframe在我的網站enbedded另一個網站,看起來像這樣:覆蓋IFRAME的CSS

<iframe src="https://youcanbook.me/?noframe=true&skipHeaderFooter=true" id="ycbmiframe" style="width:100%;height:1000px;border:0px;background-color:transparent;" frameborder="0" allowtransparency="true"></iframe> 
<script> 
    window.addEventListener && window.addEventListener("message", function(event) { 
     if (event.origin === "https://youcanbook.me") { 
      document.getElementById("ycbmiframe").style.height = event.data + "px"; 
     } 
    }, false); 
</script> 

有沒有辦法覆蓋CSS?

感謝

+0

[CSS替代iframe中的內容的正文樣式的可能的重複?](http://stackoverflow.com/questions/6494721/css-override-body-style-for-content-in-iframe) –

+0

已提問的問題:這個問題:http://stackoverflow.com/questions/217776/how-to-apply-css-to-iframe回答http://stackoverflow.com/questions/217776/how-to-apply-css-to- IFRAME/217833#217833 – bens

回答

-1

您可以使用以下方法:

$('iframe').load(function() { 
    $('iframe').contents().find("head") 
     .append($("<style type='text/css'> .my-class{display:none;} </style>")); 
}); 

發現的解決方案here