I’m making a Rich Text Editor, like this one here, and I have a problem.
I’m using an IFRAME, and the default font is Times New Roman. I want to change it to Verdana on the page load, but I have no idea how.
I tried this:
function document.body.onload() {
document.all.idContent.document.body.style.fontFamily="Verdana";
}
But it doesn’t work. The ID of my IFRAME is “idContent”
Uhm… your onload function won’t work as far as I can tell. And besides, the way you reference the iFrame element in your JavaScript also wont work as you are referring to its name, not its ID.
Try this instead:
<html>
<head>
<title>Untitled</title>
<script language="JavaScript">
onload = function()
{
document.nameOfIFrame.document.body.style.fontFamily = "Verdana";
}
</script>
</head>
<body>
<iframe name="nameOfIFrame" src="iframe.htm" width="400" height="300"></iframe>
</body>
</html>
Note the changed onload, and that the iFrame element doesn’t have an ID but a name (which I changed to “nameOfIFrame” just to make it more obvious ).
Hope that helps,
Chris
February 7, 2005, 7:16am
3
Hey all…
I am a bit confused on this… I am trying to change the font color of an iframe… but am uncertain where to put the commands?
Anybody know?
Thanks in advance,
Chris
<script language=“javascript”>
var urlstr = location.search;
function loadIframe(){
document.getElementById(“testframe”).src= “http://www.xyz ” + urlstr;
}
</script>
<body onLoad=“loadIframe()”>
<iframe id=“testframe” width=“600” height=“300”></iframe>
</body>
<script language=“javascript”>
//loadIframe();
</script>
</html>
if the page in the Iframe does not belong to same root, forget about it …
in other words if http://www.xyz does not belong to you and page with script is not at
http://www.xyz something, it is not possible for crossbrowser security reasons
Chris
February 7, 2005, 4:17pm
5
Spacefrog,
Thanks! XYZ is actually hosted on another domain… guess Ill have to live with it the way it is. Thanks again…