如何在embed html体中追加自定义样式

时间:2017-12-15 07:25:16

标签: javascript jquery

enter image description here

<embed src="url" id="idembed" width='100%' height='600' /> 
 <iframe src="url" id="idframe"   style="width: 100%;height:600px;" frameborder="0" allowfullscreen ></iframe>

请帮助我有没有办法找到嵌入内容以在头部添加自定义样式。

提前致谢..!

1 个答案:

答案 0 :(得分:0)

试试这个

<html>
<body>

  <iframe  id="emb" src="url"></iframe>

<script>
 var iframe = document.getElementByID('emb');
 var iframeDoc = iframe.contentDocument;

 // now iframeDoc variable has the reference to the document of the iframe
// assuming there is a paragraph in Iframe with id= "change"

 var p= iframeDoc.getElementByID('change');
 p.style.backgroundColor="red";

</script>
</body>
</html>