-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not possible to load SVG file content into a div element correctly #7
Comments
You need to assign a size to your container div: <div id="svgfile" style="width: 500px; height: 400px;"></div> |
OK, cool. This has solved my problem. Thank you. |
Did you solve that problem? I have the same problem. Only in webkit based browsers, in Firefox it works fine. Assigning a fixed height solves it, but I need it in a variable size. |
I was trying to find the height and width of the externally loaded svg. My container div is completely blank. I added the callback handler "svgLoaded" to the original call: $("#containerDiv").svg({loadURL: 'yourExternalSVGFile.svg', changeSize: true, onLoad: svgLoaded}); I then went to the DOM & got the first child of the container Div, using the function "getFirstChild" below to weed out text nodes:
[These internals of these functions could have been done using more JQuery-style calls.] For my use, this is in a template that gets reused. I have to "clean house" in the div at load time to make this work. I am also going to going to center & scale the child up to the div's dimensions, subject to internal padding restraints. |
Hi,
I'm trying to load the content of a SVG file into a div element. Although the content is loaded, the height of the SVG is always "null".
Here is the HTML code I'm using:
The file "lion.svg" is located in the same directory as the HTML file.
I've already tried it with different versions of jQuery. Without success.
The generated content looks like this:
If I set a value of 500 for the height in the web inspector, my SVG graphic is displayed.
Here's the error message in Safari:
Error: Invalid value for <svg> attribute height="null"
container.clientHeight
in "jquery.svg.js" line 104 is always zero.The text was updated successfully, but these errors were encountered: