modify output(replace words from X to X) in an iframe content?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • perhapscwk
    New Member
    • Sep 2007
    • 123

    modify output(replace words from X to X) in an iframe content?

    is there any ways to modify output in a iframe content?
    so let say if I have a website, now due to some reasons, i need to makesure
    all words like "the" become "xxx", if we can chnage all words in a iframe,
    then I don;t need to modify all the page but only some coding in the page which
    loaded the iframe content. thanks a lot.

    index.php
    Code:
    <FRAMESET>
      <FRAME name=contentsrc="content.php">
    </FRAMESET>
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    You are using Iframe or Frame? For Iframe we can do

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • perhapscwk
      New Member
      • Sep 2007
      • 123

      #3
      iframe...yes...

      how to do for iframe? what function?

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        Hi perhapscwk,

        using the below code you will be able to access all thediv objects in that iframe.

        Code:
        var iframeObj = document.getElementbyId('iframe');
        if ( iframeObj.contentDocument ) { // DOM
        		var divObj = iframeObj.contentDocument.getElementsByTagName('div');
        
        	} else if ( iframeObj.contentWindow ) { // IE win
        		var divObj = iframeObj.contentWindow.document.getElementsByTagName('div');
        	}
        	else
        	{
        		window.iframe.document.getElementsByTagName('div');
        	}
        After getting the div object just have a loop and change the content of the div using replace() in javascript.

        Thanks and Regards
        Ramanan Kalirajan

        Comment

        • perhapscwk
          New Member
          • Sep 2007
          • 123

          #5
          thanks. But when we click some link in iframe and new page open in the iframe
          area, it will not init the replace function again?

          Comment

          • RamananKalirajan
            Contributor
            • Mar 2008
            • 608

            #6
            Yes it will not do. You have to explicitly define on any handler. onclick itself you have call the function to replace the text.

            Thanks and Regards
            Ramanan Kalirajan

            Comment

            Working...