Re: Re: Loading SVG images dynamically and then accessing the dom

[email protected]
Newsgroups gmane.text.xml.svg.devel
Message-ID <1720598230.437883551.1353338178025.JavaMail.root@zimbra59-e10.priv.proxad.net>
Thanks Erik, I had foolishly never thought it would work so simply with responseXML.
Pranav, I think the best way is to get rid of embed or object tags. Then you can access easily every HTML and SVG elements :

<svg width="300" height="300">
    <circle r="30" cx="50" cy="50"/>
    <rect x="100" y="100" width="50" height="100"/>
</svg>
<div></div>
<script>
var svg = document.querySelector('svg');
var div = document.querySelector('div');

svg.addEventListener("mouseover",function(e) {
   var target = e.target;
   var attrs = target.attributes;
   var html = target.tagName+'<br/>';        
    
   for (var i=0,N=attrs.length;i<N;i++) {
        html += attrs[i].name+'='+attrs[i].value +"<br/>";
    }
    div.innerHTML = html;                
},false);
</script>

See http://jsfiddle.net/ybochatay/U9wZc/ for live example

Yannick

----- Mail original -----
De: "Pranav Lal" <[email protected]>
À: [email protected]
Envoyé: Lundi 19 Novembre 2012 15:08:15
Objet: RE: [svg-developers] Re: Loading SVG images dynamically and then accessing the dom






Hi all, 

My objective is to trap the mouseover and other mmouse related events and display some attributes I capture from the clicked element. I do not want to draw anything. The idea is to create an accessible SVG reader. The user would upload a SVG file. The file would be displayed in the browser. The mouse would be moved to the origin, namely 0,0. The user then starts moving the mouse. As soon as the mouse moves on to a SVG element, data about the element will be sent to the screen reader of the user or perhaps, spoken as audio. 

As of now, I am trying to get the first part working that is, trapping the events and displaying attribute information. 

Given the above use case, am I correct in thinking that using the imbed tag would be the correct approach? 

Pranav 





------------------------------------

-----
To unsubscribe send a message to: [email protected]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.