更改 iframe 内的字体[重复]

2024-03-09

我有一个 HTML 页面,其中包含iframe。我想更改 iframe 内容的样式,但我似乎无法做到这一点。

我想更改里面所有内容的字体iframe到“塔霍马”。这是我的代码:

<!DOCTYPE>

<html>
<head>

<title>phpinfo()</title>
<style type="text/css">
#outerdiv
{
width:446px;
height:246px;
overflow:hidden;
position:relative;
}

#inneriframe
{
position:absolute;
top: -508px;
left: 0px;
width: 100%;
height: 615px;
font-family: Tahoma;
}
</style>

<script>
onload = function()
{
 document.frm.document.body.style.fontFamily = "Tahoma";
}
</script>

</head>

<body>
<div id='outerdiv '>
<iframe  name="iframe" src="http://m.sarafikish.com" id='inneriframe' name="frm" scrolling=no frameborder="0"  > </iframe>
</div>    
</body></html>

这只有在以下情况下才有可能iframe's src设置为同一域上的页面或满足同源政策 https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy。您的问题并未指定您是否满足这些要求,但如果满足,您可以使用contentDocumentiframe 的属性 https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement通过 JavaScript 操作 iframe。

Example:

document.getElementById("inneriframe").contentDocument.body.style.fontFamily = "Tahoma";
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

更改 iframe 内的字体[重复] 的相关文章