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

Insert Image into SVG document

Expand Messages
  • jordangcsnt
    Hi!, i have a question, is it possible insert a image into svg document when for example I do click in a link? I tried with a java script function like this
    Message 1 of 5 , Nov 1, 2006
      Hi!, i have a question, is it possible insert a image into svg
      document when for example I do click in a link?
      I tried with a java script function like this

      function Dimage()
      {
      im= svgDocument.createElementNS(svgNS,"image");
      im.setAttributeNS(null,"id","imagen"+con[7]);
      im.setAttributeNS(null,"x",200);
      im.setAttributeNS(null,"y",200);
      im.setAttributeNS(null,"width",300);
      im.setAttributeNS(null,"height",300);
      im.setAttributeNS(null,"xlink:href","mapa.png");
      im.setAttributeNS(null,"preserveAspectRatio","none");
      svgRoot.appendChild(imagen);
      }

      I call it with <a href=javascript:Dimage();>Click</a>

      but it doesn't work someone can help me?
    • steltenpower
      ... Yes ... javascript is correct and makes the chance of confusing with Java smaller. ... So now you have a javascript object named im referring to an
      Message 2 of 5 , Nov 1, 2006
        > Hi!, i have a question, is it possible insert a image into svg
        > document when for example I do click in a link?

        Yes


        > I tried with a java script function like this

        "javascript" is correct and makes the chance of confusing with Java
        smaller.


        > im= svgDocument.createElementNS(svgNS,"image");
        > im.setAttributeNS(null,"id","imagen"+con[7]);

        So now you have a javascript object named "im" referring to an <image>
        element with the id "image"+con[7]


        > im.setAttributeNS(null,"xlink:href","mapa.png");

        I think you should change this to ..(xlinkNS,"href","mapa.png");
        where you first define xlinkNS="http:// ....... "; (look it up)


        > svgRoot.appendChild(imagen);

        I think you meant ..(im);


        I think this quick reaction and maybe some Googling will get this
        sorted out.

        Cheers,

        Ruud
        http://svg.startpagina.nl
      • unkerjay
        Has anyone here posted SVG files to personal webpages at comcast.net with any success? If so, could you point me to such examples. I don t seem to be having
        Message 3 of 5 , Nov 1, 2006
          Has anyone here posted SVG files to personal webpages
          at comcast.net with any success?

          If so, could you point me to such examples.

          I don't seem to be having any luck with it:

          I can view svg from wikimedia for example.

          and from:

          http://www.croczilla.com/svg/samples/

          but not:

          http://mywebpages.comcast.net/mmeroom/kc_flag.htm

          or

          http://mywebpages.comcast.net/mmeroom/kc_flag.html (flash/swf)

          or

          http://mywebpages.comcast.net/mmeroom/kc_flag.swf

          or

          http://mywebpages.comcast.net/mmeroom/kc_wa_flag.svg

          None of these files display properly from firefox on my pc.

          I know firefox is supposed to have "native format" support for svg files.

          The Adobe SVG viewer is supposed to add SVG viewing support to IE.

          I don't seem to be having problems in the latest version of Opera.

          But, nothing but problems in Firefox.

          I've been told it's a possible MIME-type misconfiguration, possibly
          server side, but, I have no way, that I know of, of knowing what
          Comcast's server configuration is, or for that matter doing that
          much about it.

          Is there a workaround?

          Is it something I'm doing wrong?

          If so, what?

          Thanx.
        • G. Wade Johnson
          Hello, On Wed, 01 Nov 2006 15:18:25 -0800 ... A quick check shows that you definitely have the MIME-type problem. The Content-type on your SVG files is
          Message 4 of 5 , Nov 1, 2006
            Hello,

            On Wed, 01 Nov 2006 15:18:25 -0800
            unkerjay <unkerjay@...> wrote:

            > Has anyone here posted SVG files to personal webpages
            > at comcast.net with any success?
            >
            > If so, could you point me to such examples.
            >
            > I don't seem to be having any luck with it:
            >
            > I can view svg from wikimedia for example.
            >
            > and from:
            >
            > http://www.croczilla.com/svg/samples/
            >
            > but not:
            >
            > http://mywebpages.comcast.net/mmeroom/kc_flag.htm
            >
            > or
            >
            > http://mywebpages.comcast.net/mmeroom/kc_flag.html (flash/swf)
            >
            > or
            >
            > http://mywebpages.comcast.net/mmeroom/kc_flag.swf
            >
            > or
            >
            > http://mywebpages.comcast.net/mmeroom/kc_wa_flag.svg
            >
            > None of these files display properly from firefox on my pc.
            >
            > I know firefox is supposed to have "native format" support for svg
            > files.
            >
            > The Adobe SVG viewer is supposed to add SVG viewing support to IE.
            >
            > I don't seem to be having problems in the latest version of Opera.
            >
            > But, nothing but problems in Firefox.
            >
            > I've been told it's a possible MIME-type misconfiguration, possibly
            > server side, but, I have no way, that I know of, of knowing what
            > Comcast's server configuration is, or for that matter doing that
            > much about it.
            >
            > Is there a workaround?
            >
            > Is it something I'm doing wrong?

            A quick check shows that you definitely have the MIME-type problem. The
            Content-type on your SVG files is "text/plain". It should be
            "image/svg+xml".

            See http://wiki.svg.org/Server_Configuration:Apache for information on
            fixing this issue.

            G. Wade
            --
            Those who live by the sword get shot by those who don't.
          • G. Wade Johnson
            On Wed, 01 Nov 2006 15:18:25 -0800 ... Oops! I spoke too soon. The Apache instructions won t help on the Netscape server, I don t think. That wiki page does
            Message 5 of 5 , Nov 1, 2006
              On Wed, 01 Nov 2006 15:18:25 -0800
              unkerjay <unkerjay@...> wrote:

              > Has anyone here posted SVG files to personal webpages
              > at comcast.net with any success?

              Oops! I spoke too soon. The Apache instructions won't help on the
              Netscape server, I don't think. That wiki page does give much of the
              information you need to know about configuration though.

              G. Wade
              --
              That's what I love about GUIs: They make simple tasks easier, and
              complex tasks impossible.
              -- John William Chambless, <39v25i$2rbc@...>
            Your message has been successfully submitted and would be delivered to recipients shortly.