Why is my svg file not displaying in my browser?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpuser123
    New Member
    • Dec 2009
    • 108

    Why is my svg file not displaying in my browser?

    I just implemented a small svg script...
    Code:
    <html
    xmlns:svg="http://www.w3.org/2000/svg">
    <body>
    
    <p>This is an HTML paragraph</p>
    
    <svg:svg width="300" height="100" version="1.1" >
    <svg:circle cx="100" cy="50" r="40" stroke="black"
    stroke-width="2" fill="red" />
    </svg:svg>
    
    </body>
    </html>
    When I preview this script in my browser,I am not able to view the svg ....I am using Mozilla firefox 3.2...
    ang my file name is test.html...
    Why i am not able to see the circle???Where have i erred??
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I believe, the problem is that you try it with HTML. you would need to use XHTML.

    Comment

    • phpuser123
      New Member
      • Dec 2009
      • 108

      #3
      Thanks ,it did work..

      Comment

      • Stanislaw
        New Member
        • Jul 2010
        • 4

        #4
        re: Why is my svg file not displaying in my browser?

        I have the same problem.
        I use Drupal and all my pages don't have the .xhtml extension.
        May be there is a way to create some declaration inside .html document to make firefox display svg without .html extension?
        I can't find any solutions yet.
        Thank you.

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          is it a link to an svg file or inline svg?

          Comment

          • Stanislaw
            New Member
            • Jul 2010
            • 4

            #6
            re:Why is my svg file not displaying in my browser?

            It is inline svg.
            Yesterday i got some solution. I found svgweb library written in javascript. It works, i implemented it into my drupal site, but i'm still interested, may be there is a solution, that is easier. Thank you.

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              the easiest solution is (as has been previously stated) using XHTML (with at least the text/xml or better application/xhtml+xml header (i.e. use the xhtml extension))

              HTML is not able to display such XML, that’s why XHTML was invented.

              Comment

              • Stanislaw
                New Member
                • Jul 2010
                • 4

                #8
                re: Why is my svg file not displaying in my browser?

                And what if i am not able to use xhtml extensions?
                It's drupal with .php files.
                What to do in this case? Use mod_rewrite rules or...?
                I was looking for a possibility of using .html or .php files with some declaration in DOCTYPE or <html xmlns...>, but the today's solution is still the using of svgweb.

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  if you’re using PHP, use the header() function to send the MIME type.

                  again, you cannot use inline SVG in native HTML files.

                  Comment

                  • Stanislaw
                    New Member
                    • Jul 2010
                    • 4

                    #10
                    re: Why is my svg file not displaying in my browser?

                    I have <svg>...</svg> block that i want to be displayed.
                    Could you please show any _simple_ example of using header() function? Where it should be used?
                    I am a complete newbie in Drupal, PHP, svg...

                    Comment

                    • Dormilich
                      Recognized Expert Expert
                      • Aug 2008
                      • 8694

                      #11
                      where: before you start any (HTML) output (i.e. top of the page)

                      _simple_ example: header("Content-Type: application/xhtml+xml");

                      Comment

                      Working...