Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2012-06-28 02:36:21

susitha.senarath
New member
Registered: 2012-06-05
Posts: 6

Read content of Xinha dynamically

Hi,

I want to dynamically read what has typed in Xinha reader without submitting the content. I use a javascript as follows.

<script type="text/javascript">
    var old = '';
    function update()
    {
          var textarea = document.getElementById('myTextArea');
          var d = dynamicframe.document;
 
          if (old != textarea.value)
          {
                old = textarea.value;
                d.open();
                d.write(old);
                d.close();
          }
    }
  </script>

but what I type in editor cannot b read by value of the text area. I saw there as a iframe created on run time by xinha with the id "XinhaIFrame_myTextArea". I can see the content in it using firebug. But I cannot get it's content too.

Can someone help me here.

Offline

#2 2012-06-28 05:25:47

susitha.senarath
New member
Registered: 2012-06-05
Posts: 6

Re: Read content of Xinha dynamically

Got it solved. for anyone interest following is how I get it done

<script type="text/javascript">
    var old = '';
    function update()
    {
          var textarea = document.getElementById('XinhaIFrame_myTextArea');
          var con = textarea.contentWindow.document.body.innerHTML;
          var d = dynamicframe.document;
 
          if (old != con)
          {
                old = con;
                d.open();
                d.write(old);
                d.close();
          }
         
          var frm = frames['dynamicframe'].document;
        var otherhead = frm.getElementsByTagName("head")[0];
        var link = frm.createElement("link");
        link.setAttribute("rel", "stylesheet");
        link.setAttribute("type", "text/css");
        link.setAttribute("href", "files/full_example.css");
        otherhead.appendChild(link);


    }
  </script>

Offline

Board footer

Powered by FluxBB