Loading ...
Sorry, an error occurred while loading the content.

Load Div In Foreign Object Element

Expand Messages
  • jcdeering1
    I am at the last stage of publishing what I think is a helpful SVG demo. The last thing I need to do is load through script a div that is in a foreign object
    Message 1 of 4 , Mar 19, 2014
    • 0 Attachment
      I am at the last stage of publishing what I think is a helpful SVG demo. The last thing I need to do is load through script a div that is in a foreign object element. I am assuming this is possible by first getting the foreign object element and then finding the display element inside it, but I don't know how to do this.
      Without the foreign object the below script works well. Can anyone help rewrite this code snippet?

      <script type="text/javascript">
      function load_data(temp) {
      var req = new XMLHttpRequest();
      req.open("GET", temp, false);
      req.send(null);
      var page = req.responseText;
      document.getElementById("display").innerHTML = page;
      }
      </script>

      <foreignobject x="0" y="0" width="100%" height="100%">
      <div id="display">
      </div>
      </foreignobject>
       
      Help, as always is appreciated.

      James
    • Mark T
      Hi James, This is proving elusive to me. The theory would be to parse text/xml containing xhtml within a svg document. Then attach this to a foreignObject.
      Message 2 of 4 , Mar 20, 2014
      • 0 Attachment
        Hi James,
        This is proving elusive to me.
        The theory would be to parse text/xml containing xhtml within a svg document.
        Then attach this to a foreignObject.
        This is as far as I get: http://govirtual.com.au/Tests/TestFOdynamicAddText.svg

        There may be a security restriction imposed by the parser.
        Content is being discarded.
        The rules for this will be found .somewhere.
        I recall there being a bug raised "Why don't we have an xhtml parser?"

        * "Does document.write work in XHTML?No. Because of the way XML is defined, it is not possible to do tricks like this, where markup is generated by scripting while the parser is still parsing the markup.You can still achieve the same effects, but you have to do it by using the DOM to add and delete elements."

        There will be an explain in the browser source code .somewhere.

        MarkT

        On Thu, Mar 20, 2014 at 11:44 AM, <jcdeering1@...> wrote:

        I am at the last stage of publishing what I think is a helpful SVG demo. The last thing I need to do is load through script a div that is in a foreign object element. I am assuming this is possible by first getting the foreign object element and then finding the display element inside it, but I don't know how to do this.

      • jcdeering1
        Wow! Didn t think it would be that difficult! Fortunately, it is not a deal breaker for my demo. Thanks for the information. James
        Message 3 of 4 , Mar 20, 2014
        • 0 Attachment
          Wow! Didn't think it would be that difficult! Fortunately, it is not a deal breaker for my demo. Thanks for the information.

          James
        • Mark T
          Difficulty is possibly one factor to the resistive adoption of xhtml. The restriction of innerHtml, is by design FWICTell.
          Message 4 of 4 , Mar 20, 2014
          • 0 Attachment
            Difficulty is possibly one factor to the resistive adoption of xhtml.
            The restriction of innerHtml, is by design FWICTell.
            https://developer.mozilla.org/en-US/docs/Web/API/document.createTextNode
            I've updated the test to show that nodes can be created within the doc.
            Not tested in all versions of all browsers!

            MarkT


            On Fri, Mar 21, 2014 at 5:34 AM, <jcdeering1@...> wrote:
             

            Wow! Didn't think it would be that difficult!

          Your message has been successfully submitted and would be delivered to recipients shortly.