SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting the text frame an iframe

    Lets say I have an I-frame called blah.
    I want to add text to it and I have this function:

    Code:
    function addSmiley(textToAdd)
    {
      var thewindow = window.frames['blah'];
      thewindow.document.open();
      thewindow.document.write(+textToAdd);
      thewindow.document.close();
     
    }
    Unfortunately, when I click on the smiley, it completely replaces all the text in the Iframe with the symbol for that smiley. How do I get it to add the symbol for the smiley to the text already there.

    Basically I want to know the object property for all the text currently in the I-frame.

    Its not thewindow.document.value like I thought it was.

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.write() can only be used while the page is loading -- if it isn't it will replace the page with what ever it writes out. The Document Object Model (DOM) can be used to add elements, text, etc. to the page without reloading it.

    Rough Guide to the DOM
    JavaScript tutorial - W3C DOM introduction
    http://www.quirksmode.org/js/contents.html#dom
    http://www.brainjar.com/
    http://developer.apple.com/internet/...ent/dom2i.html
    http://developer.mozilla.org/en/docs/DOM:document
    http://developer.mozilla.org/en/docs..._DOM_Reference
    http://digital-web.com/articles/form...d_the_w3c_dom/
    http://www.w3.org/DOM/
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out, I had to set another object and fill it.


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
  •