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

Hiding SVG Elements in #document

Expand Messages
  • srcard
    Hi, I ve exported some HTML / SVG from Visio. I d like to hide some elements within it. The problem is that I m unable to use jQuery selectors to get access
    Message 1 of 2 , Apr 16, 2013
      Hi,

      I've exported some HTML / SVG from Visio. I'd like to hide some elements within it.

      The problem is that I'm unable to use jQuery selectors to get access to any of the SVG elements - it appears to be due to the #document.

      How can I get access to elements that are within the following, please?

      <body>
      <object width="100%" height="100%" id="SVGViewer1" data="svg_1.svg" type="image/svg+xml" viewastext="">
      #document
      <svg ...>
      ...
      </svg>
      </object>
      </body>

      Many thanks,

      Simon
    • Bjoern Hoehrmann
      ... This looks like copied and pasted from some kind of document tree viewer as one may find them in some debuggers and development environments. I d imagine
      Message 2 of 2 , Apr 19, 2013
        * srcard wrote:
        >I've exported some HTML / SVG from Visio. I'd like to hide some elements within it.
        >
        >The problem is that I'm unable to use jQuery selectors to get access to any of the
        >SVG elements - it appears to be due to the #document.
        >
        >How can I get access to elements that are within the following, please?
        >
        ><body>
        > <object width="100%" height="100%" id="SVGViewer1" data="svg_1.svg" type="image/svg+xml" viewastext="">
        > #document

        This looks like copied and pasted from some kind of document tree viewer
        as one may find them in some debuggers and development environments. I'd
        imagine `#document` is used as a placeholder for the embedded image, and
        the image is not in fact inline SVG code. The <object> element uses the
        HTMLObjectElement interface, see e.g.

        https://developer.mozilla.org/en-US/docs/DOM/HTMLObjectElement

        and the `contentWindow` and `contentDocument` attributes are what you
        are looking for. For my personal homepage I found some time ago that it
        is better to use `<iframe>` though, if you want it to work across many
        browsers, so you may have to try that instead.
        --
        Björn Höhrmann · mailto:bjoern@... · http://bjoern.hoehrmann.de
        Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
        25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
      Your message has been successfully submitted and would be delivered to recipients shortly.