To answer my question, onload event seems to be working, so instead of
ready, it should be load function.

mysvg.load(function(){
       .... above code goes here ....
       });

It is similar to images. Firefox DOM is ready before an image is
ready. It looks like it is also ready before an object fully loaded.


On Nov 20, 3:07 pm, balamir <[EMAIL PROTECTED]> wrote:
> I'm using SVG with jQuery and I'm aware of jQuery SVG plugin and
> Marvin's discussion athttp://marvin.elte.hu/balu/content/jquery-svg.
> For developmental reasons, I'm trying to embed SVG as an object to my
> DOM.
> For example:
>
>  var  mysvg= $('<object id="object"  data="ellipse.svg" type="image/svg
> +xml" width="160" height="100" style="position:absolute;top:0px;left:
> 0px;z-index:100"></object>');
>  mycontainer.append(mysvg); //append it to the container
>
> My aim is to update SVG parameters when it is ready.
>
> For this purpose  I get SVG root using the example 
> athttp://jwatt.org/svg/demos/scripting-across-object.html
>
> var object = document.getElementById('object');
>   if (object && object.contentDocument)
>     svgdoc = object.contentDocument;
>     svgdoc.getElementById('ellipse').setAttribute("rx",200); //modify
> the content
>   else try {
>     svgdoc = object.getSVGDocument();
>        svgdoc.getElementById('ellipse').setAttribute("rx",200); //
> modify the content
>   }
>   catch(exception) {
>     alert('Neither the HTMLObjectElement nor the GetSVGDocument
> interface are implemented');
>   }
>
>  Because the object is not ready, the above code always creates an
> exception. The first "if" fails. The getSVGDcoument  also fails as  it
> does not exist. My solution for making sure object is ready  is to
> move the above code to mysvg's ready function.
>
>   mysvg.ready(function(){
>        .... above code goes here ....
>       });
>
>  Now this ready function is called when object is ready. However, even
> when object is ready, and svg is set correctly, svg.getElementById
> returns null. When I call svgdoc.getElementById later in the
> execution, it works fine (even if I add it to catch part, supposed to
> be giving errors, it works fine).
>
> I think jQuery assumes object is ready before SVG's DOM is created. I
> know that jQuery is specificly developed for Javascript but any
> suggestions how can I add my function only when everything (both
> javascript and SVG DOMs) is ready (or make sure jQuery is aware of
> SVG's DOM?)

Reply via email to