Re: HTML accessing Javascript from SVG

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: HTML accessing Javascript from SVG

Jonathan Watt-2
Hi,

Without reading much of the below, I'll point you to the following two
docs. Read the comments in the source. It's the *window* object that you
need to fetch.

   http://jwatt.org/svg/demos/scripting-across-embed.html
   http://jwatt.org/svg/demos/scripting-across-object.html

Regards,
Jonathan

[hidden email] wrote:

> I am trying to access a simple Javascript function, which is embedded
> in an SVG doc, which is itself embedded in some HTML.  However, no
> matter what I do, or which Wikis I read, nothing seems to work.  Does
> any one have a a good idea of how to do this (and make it work for
> Firefox).
>
> Here's an example of what I've tried:
>
> SVG text
> ----------
> <?xml version="1.0" ?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" >
> <svg id="main" xml:space="preserve" width="640" height="480"
> zoomAndPan="disable" onmousedown="mouseclick(evt)"
> onmousemove="moveMouse(evt)" onmouseup="endSelect(evt)"
> onload="initSVG(evt);">
>   <script language="JavaScript">//<![CDATA[
> var featureselect;
> function enableFeatureSelect()
>     {
>       featureselect = 1 ;
>     }
>   //]]>
>   </script>
> <svg id="root" width="640" height="480">
> .....SVG stuff
> </svg>
>
> HTML text
> ----------
> <html lang="en-us">
> <head>
>
> <script language="JavaScript" type="text/javascript">
>
>   var svgdoc
>
>   function EnableFeatureSelect(){
>    //top.document.embeds[map].enableFeatureSelect()
>    //window.enableFeatureSelect()
>    //svgDoc.enableFeatureSelect()
>    svgdoc = top.document.map.getSVGDocument();
>   }
> </script>
> <meta http-equiv="Content-Type" content="text/html;
> charset=windows-1252" />
> <title>Page 1</title>
>
> </head>
> <body >
> <embed width="640" height="480" src="map.svg" name="map"
> type="image/svg+xml">
> <script>
>  svgdoc.EnableFeatureSelect();
> </script>
> </body>
> </html>
>
_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg