SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Froot r gewd SubKamran's Avatar
    Join Date
    May 2002
    Location
    North Star State
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing the font of a "iframe"

    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:

    Code:
    function document.body.onload() {
    document.all.idContent.document.body.style.fontFamily="Verdana";
    }
    But it doesn't work. The ID of my IFRAME is "idContent" :-)
    "Sometimes little is more."
    Kamran A
    Web Dev/Designer
    Keyboard not found: Please Press F1 to Continue

  2. #2
    Bangarang! Karloff's Avatar
    Join Date
    Mar 2003
    Location
    Manchester, United Kingdom
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:
    Code:
    <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,
    Karl


    I'm desperately trying to figure out why Kamikaze pilots wore helmets. - George Carlin

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    iframe font color change

    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>

  4. #4
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  5. #5
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Spacefrog,
    Thanks! XYZ is actually hosted on another domain... guess Ill have to live with it the way it is. Thanks again...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •