# 2010-05-10 Javascript

Last edit

> *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. :warning:

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.

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

    svgEditor.loadFromString('<svg>...</svg>');

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">
</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.

Tags:

Last edit

Changed:

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

to

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

Changed:

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

to

> -- [[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.