2010-05-10 Javascript

Difference between revision 4 and current revision

Summary: (^|:)warning: → ⚠

No diff available.

I still haven’t learnt Javascript. Right now I’m trying to integrate svg-edit and Oddmuse. This requires some Javascript voodoo that escapes me.

If you upload a SVG file to http://www.emacswiki.org/test/SVG_Test, you’ll be able to look at it. I’m using an iframe to do that.

If you then click on Edit this page and then on Edit image in the browser, you’ll get the SVG editor.

What I’m lacking is loading and saving the image!

If you look around the svg-edit project’s pages, you’ll note example code like the following:


What I don’t understand is where this code runs and how svgEditor is set.

If I simply add the following to the top of the page, inside the header, then Firebug will tell me that the svgEditor object does not exist.

<script type=“text/javascript”> svgEditor.loadFromString(’<svg>…</svg>’); </script>

What now? Is this a variable “inside” the iframe? Is this something I need to initialize by calling a function? Which one?

Update: Perhaps I’m running into some cross-site scripting protection. The site runs on www.emacswiki.org, the SVG editor runs on svg-edit.googlecode.com. Using Firebug, I run document.getElementsByName('svgEditor')[0].getSVGDocument().setUserData('fd') and get an error message. ⚠


Show Google +1


Last edit

Summary: fixing links


< -- AlexSchroeder 2010-05-13 20:41 UTC


> -- [[AlexSchroeder]] 2010-05-13 20:41 UTC


< -- AlexSchroeder 2010-05-13 23:20 UTC


> -- [[AlexSchroeder]] 2010-05-13 23:20 UTC

This site is great!

– Kate 2010-05-13 10:38 UTC

It looks like you’re not including the javascript library that provides the SVG editing functions.

Harald 2010-05-13 12:32 UTC

Hah, I’m seeing the light. Copying the script over to localhost has fixed this. I’ve come a long way. Now I need MIME encoding in Javascript, and probably a cool Save dialog – or a little rewrite.

AlexSchroeder 2010-05-13 20:41 UTC

AlexSchroeder 2010-05-13 23:20 UTC

Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.