<p>To add a svg graphics in html page, it is common to use object tag to wrap it like this:</p>

<pre><code>&lt;object id="svgid" data="mysvg.svg" type="image/svg+xml" 
  wmode="transparent" width="100" height="100"&gt;

this browser is not able to show SVG: &lt;a linkindex="3"
href="http://getfirefox.com"&gt;http://getfirefox.com&lt;/a&gt; 
is free and does it!
If you use Internet Explorer, you can also get a plugin: 
&lt;a linkindex="4" href="http://www.adobe.com/svg/viewer/install/main.html"&gt;
http://www.adobe.com/svg/viewer/install/main.html&lt;/a&gt;

&lt;/object&gt;
</code></pre>

<p>If you do not use width and height attributes in the object tag, the svg will be displayed in full size. Normally I get svg files from Open Graphics Library for testing. Is there any way to get svg's size by using JavaScript? Or maybe I should just look at the svg xml file to find out the size from the top svg tag?</p>

> Is there any way to get svg's size by using JavaScript?
No and yes.
No:
JavaScript won't be able to access the SVG file contents that are sitting in the browser.
So it wouldn't be possible to have a page containing an arbitrary SVG image and then have JavaScript determine anything from the SVG file itself.
The only data JS can access it that contained within the page's DOM: the original markup plus any JS-related modifications to the DOM. You could access the
```
object
```
element's attributes and descendant nodes, but that won't give you visibility of anything more than what you can see if you look at the page markup yourself.
Yes:
JS (in modern browsers) can parse any XML string into a DOM and then access the content using DOM-based methods.
You could get the SVG file contents by issuing an xmlHttpRequest-style request (i.e. JS performs an HTTP GET on the SVG file's URL). JS would then have the SVG file's full XML string and you can then access anything you like.
> Or maybe I should just look at the svg xml file to find out the size from the top svg tag?
This would be more feasible by far.
The only JS-based solution would require JS to perform a GET request on the SVG file's URL (as above), which is unlikely to be feasible - each page load might result in double-downloading each SVG file, and the parsing of the SVG's XML into a DOM by JS might be too resource intensive.
Having JS retrieve the SVG's XML content and parse it into a DOM to retrieve only the image dimensions is a bit overkill. It's perfectly possible, but generally not practical.
Querying the SVG's XML content server-side, determining a suitable width and height and then dynamically adding the
```
width
```
and
```
height
```
attributes prior to returning markup to the browser would be your best bet.