471,570 Members | 973 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

Why is my svg file not displaying in my browser?

108 100+
I just implemented a small svg script...
Expand|Select|Wrap|Line Numbers
  1. <html
  2. xmlns:svg="http://www.w3.org/2000/svg">
  3. <body>
  5. <p>This is an HTML paragraph</p>
  7. <svg:svg width="300" height="100" version="1.1" >
  8. <svg:circle cx="100" cy="50" r="40" stroke="black"
  9. stroke-width="2" fill="red" />
  10. </svg:svg>
  12. </body>
  13. </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??
Jun 1 '10 #1
10 7134
8,656 Expert Mod 8TB
I believe, the problem is that you try it with HTML. you would need to use XHTML.
Jun 1 '10 #2
108 100+
Thanks ,it did work..
Jun 1 '10 #3
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.
Jul 14 '10 #4
8,656 Expert Mod 8TB
is it a link to an svg file or inline svg?
Jul 15 '10 #5
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.
Jul 15 '10 #6
8,656 Expert Mod 8TB
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.
Jul 15 '10 #7
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.
Jul 15 '10 #8
8,656 Expert Mod 8TB
if you’re using PHP, use the header() function to send the MIME type.

again, you cannot use inline SVG in native HTML files.
Jul 15 '10 #9
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...
Jul 15 '10 #10
8,656 Expert Mod 8TB
where: before you start any (HTML) output (i.e. top of the page)

_simple_ example: header("Content-Type: application/xhtml+xml");
Jul 15 '10 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Mei Qin | last post: by
3 posts views Thread by Daniel | last post: by
1 post views Thread by asad | last post: by
reply views Thread by =?Utf-8?B?c2NvdHRybQ==?= | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.