How to embed svg in HTML reading from DATABASE
I am reading svg file stored in mysql db in longblob format in an gwt application. I am tansferring the file in string format from servlet to client side as json using HTTP. Now i want开发者_如何学运维 to embed it into HTML to display in a panel.
the HTML tag provided is How to embed it without creating a temporary file?
I'm not really sure I'm getting the problem right but you can embed SVG in HTML simply as inline SVG. Sample:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SVG embedded inline in XHTML</title>
</head>
<body>
<h1>SVG embedded inline in XHTML</h1>
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">
<circle cx="150" cy="100" r="50" />
</svg>
</body>
</html>
(See http://wiki.svg.org/Inline_SVG for more information)
So you could just embed the SVG code before sending the HTML to the client (or if you generate the HTML on client side embed it there).
This is how I embed SVG into HTML.
<!--[if IE]>
<object id="svgImage" src="example.svg" classid="image/svg+xml">
<![endif]-->
<!--[if !IE]>-->
<object id="svgImage" data="example.svg" type="image/svg+xml">
<!--<![endif]-->
</object>
I also incorporate SVGWeb into the project so that the content will function in Internet Explorer. This does have the disadvantage of requiring flash, but that's not a problem for most people, plus it's only enabled for browsers that don't have native SVG support by default.
精彩评论