Read SVG (using JavaScript) H - E- L - P ! ! !

O

Olumide

How can I use EXTERNAL JavaScript code to read (and modify) an SVG
file/object? Can JavaScript do this or do I have to resort to Batik?

IMPORTANT NOTE:
The JavaScript code CANNOT be embedded in the SVG file, because it is
server-side generated.

Thank You


- Olumide
 
J

Jason Davis

Olumide said:
How can I use EXTERNAL JavaScript code to read (and modify) an SVG
file/object? Can JavaScript do this or do I have to resort to Batik?

IMPORTANT NOTE:
The JavaScript code CANNOT be embedded in the SVG file, because it is
server-side generated.

Thank You


- Olumide

Do you need to save the modifications? If not, just load it like any
other XML document (through XmlHttpRequest() or createDocument() and
document.load()), and use the DOM to manipulate it.

-Jason Davis
 
O

Olumide

... just load it like any
other XML document (through XmlHttpRequest() or createDocument() and
document.load()), and use the DOM to manipulate it.



Thanks Jason, I will look into this. The problem however is that I have
a multiframe document that looks like this:


|-----------------------------------------------|
| | |
| | |
| | |
| | |
| Left Frame | Right Frame |
| [SVG] | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
|-----------------------------------------------|

The Left Frame is an SVG object while the Right Frame is a an HTML
document with JavaScript code in its head section. My intention is to
have the SVG object (in the left frame) modified by the javascript code
in the right frame. (The HTML document in the right frame is server-side
generated.)


Er ... can document.load() still "load" the SVG document even though it
is already loaded in the left frame?

Thanks


- Olumide
 
J

Jason Davis

Can't you just go:

top.leftframename.document

And reference the SVG document that way? With the Adobe SVG Viewer you
might have to rely on method calls (I don't have much experience with
the ASV DOM implementation), but in Mozilla you should be able to access
the SVG document like that, and use standardized DOM interfaces (DOM2
Core and the SVG DOM for example) to manipulate it on the fly.

-Jason Davis
... just load it like any other XML document (through XmlHttpRequest()
or createDocument() and document.load()), and use the DOM to
manipulate it.




Thanks Jason, I will look into this. The problem however is that I have
a multiframe document that looks like this:


|-----------------------------------------------|
| | |
| | |
| | |
| | |
| Left Frame | Right Frame |
| [SVG] | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
|-----------------------------------------------|

The Left Frame is an SVG object while the Right Frame is a an HTML
document with JavaScript code in its head section. My intention is to
have the SVG object (in the left frame) modified by the javascript code
in the right frame. (The HTML document in the right frame is server-side
generated.)


Er ... can document.load() still "load" the SVG document even though it
is already loaded in the left frame?

Thanks


- Olumide
 
O

Olumide

Jason said:
Can't you just go:

top.leftframename.document

And reference the SVG document that way? With the Adobe SVG Viewer you
might have to rely on method calls (I don't have much experience with
the ASV DOM implementation), but in Mozilla you should be able to access
the SVG document like that, and use standardized DOM interfaces (DOM2
Core and the SVG DOM for example) to manipulate it on the fly.



Can anyone provide a hint or (web) link showing how this can be done?

Thanks

- Olumide
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top