Comunication xul with file svg

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Comunication xul with file svg

xiongh
I have this file.xul :

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns:svg="http://www.w3.org/2000/svg">


<html:html>
<html:body>
        <html:body><html:embed src="m.svg" width="900" height="900"
type="image/xml+svg"/>  </html:body>
</html:body>
</html:html>
</window>

Now,Can I comunicate file xul with file.svg?How can I?

_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: Comunication xul with file svg

Jonathan Watt-2
Hi xiongh,

Take a look at the following demos.

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

Regards,
Jonathan

xiongh wrote:

> I have this file.xul :
>
> <?xml version="1.0"?>
> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
>
> <window
> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
> xmlns:html="http://www.w3.org/1999/xhtml"
> xmlns:svg="http://www.w3.org/2000/svg">
>
>
> <html:html>
> <html:body>
> <html:body><html:embed src="m.svg" width="900" height="900"
> type="image/xml+svg"/>  </html:body>
> </html:body>
> </html:html>
> </window>
>
> Now,Can I comunicate file xul with file.svg?How can I?
>
_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: Comunication xul with file svg

Martin Honnen-3
In reply to this post by xiongh


xiongh wrote:


> <window
> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
> xmlns:html="http://www.w3.org/1999/xhtml"
> xmlns:svg="http://www.w3.org/2000/svg">
>
>
> <html:html>
> <html:body>
> <html:body><html:embed src="m.svg" width="900" height="900"
> type="image/xml+svg"/>  


> Now,Can I comunicate file xul with file.svg?How can I?

Are you using the Adobe SVG viewer plugin for rendering the SVG? Or are
you using Firefox 1.5 (beta/release candidate) with its native SVG support?

The Adobe SVG viewer (version 3) plugin is not scriptable with current
Mozilla versions, indeed Adobe does not even support it for Mozilla
officially.
The only thing possibe with the viewer might be using the function
   browserEval
from script inside of the SVG document but I have no idea whether that
has any meaningful effect when the SVG sits inside of an XHTML embed in
a XUL document.


Note that there is an SVG group netscape.public.mozilla.svg so please
keep SVG questions there. But it is mainly for the native SVG support in
Mozilla.

--

        Martin Honnen
        http://JavaScript.FAQTs.com/
_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: Comunication xul with file svg

xiongh
I use Firefox 1.5 (release candidate).In more if i reload the file xul
FireFox go in crash

_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: Comunication xul with file svg

Martin Honnen-3


xiongh wrote:

> I use Firefox 1.5 (release candidate).In more if i reload the file xul
> FireFox go in crash

Then consider filing a bug report on bugzilla.mozilla.org.

As for the communciation between script in XUL and script in the
embedded SVG, Jonathan's answer should help if that is Firefox 1.5 with
native SVG support.

--

        Martin Honnen
        http://JavaScript.FAQTs.com/
_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: Comunication xul with file svg

xiongh
In reply to this post by Jonathan Watt-2
I have proved to use this file but they don't help me.
This is my attempt:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns:svg="http://www.w3.org/2000/svg"  onload="init()"


>

<script >



var svgdoc = null;
var svgwin = null;

function init()
{

  // FIRST WE TRY TO OBTAIN A REFERENCE TO THE SVG DOCUMENT.
  //
  // Mozilla with native SVG support and ASV running in IE both support
the
  // GetSVGDocument interface for the <embed> object.
  //
  //   http://w3.org/TR/SVG11/struct.html#InterfaceGetSVGDocument
  //
  // Unfortunately ASV in IE doesn't allow us to check if the method
  // getSVGDocument() exists without calling it. Since calling a
function that
  // doesn't exist will cause an error we must be prepared to catch an
  // exception.


  var embed = document.getElementById('em');
  try {

    svgdoc = embed.getSVGDocument();
  }
  catch(exception) {
    alert('The GetSVGDocument interface is not supported');
  }

  // If the GetSVGDocument interface is supported then the global
variable
  // svgdoc will now contain a reference to the SVG document. Otherwise
it will
  // be null.
  //
  // NOW WE TRY TO OBTAIN A REFERENCE TO THE SVG DOCUMENT'S "window"
OBJECT.
  //
  // The W3C does not provide a direct way to obtain the "window"
object for
  // the SVG document from the <embed> element (obviously, since it's
not a W3C
  // tag). The W3C way to access the SVG document's "window" object is
via the
  // SVG document itself, using the defaultView attribute of the
DocumentView
  // interface.
  //
  //
http://www.w3.org/TR/DOM-Level-2-Views/views.html#Views-DocumentView
  //
  // ASV in IE doesn't implement the W3C's DocumentView interface
(yet), so we
  // also try to access the SVG document's "window" object using the
non-W3C
  // standard properties 'window' and non-W3C standard function
getWindow() on
  // the <embed> object. Again ASV doesn't allow us to check whether
getWindow()
  // is supported, so we need to be ready to catch an exception if
calling it
  // causes an error.

  if (svgdoc &amp;&amp; svgdoc.defaultView)  // try the W3C standard
way first
    svgwin = svgdoc.defaultView;
  else if (embed.window)
    svgwin = embed.window;
  else try {
    svgdoc = embed.getWindow();
  }
  catch(exception) {
    alert('The DocumentView interface is not supported\r\n' +
          'Non-W3C standard methods of obtaining "window" also
failed');
  }


  // If we failed to get a reference to the SVG document's "window"
then svgwin
  // will still be null.
}


</script>

<html:html lang="en">

  <html:p>
      To test JavaScript access from the HTML document to the SVG
document
      <html:a href="javascript:alert('found: ' + svgdoc)">click
here</html:a>.
      To test JavaScript access from the HTML document to the SVG
document's "window"
      <html:a href="javascript:alert('found: ' + svgwin)">click
here</html:a>
      (accessing the SVG document's "window" allows you to access
variables and
      functions defined in scripts in the SVG document).
    </html:p>

                <html:embed id="em" src="m.svg" width="500" height="500"
type="image/xml+svg" />


</html:html>

</window>

But when I load this file I obtain:
 catch(exception) {
    alert('The DocumentView interface is not supported\r\n' +
          'Non-W3C standard methods of obtaining "window" also
failed');

How Can I do?

_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: Comunication xul with file svg

xiongh
In reply to this post by Jonathan Watt-2
 have proved to use this file but they don't help me.
This is my attempt:


<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window

xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns:svg="http://www.w3.org/2000/svg"  onload="init()"





<script >

var svgdoc = null;
var svgwin = null;


function init()
{


  // FIRST WE TRY TO OBTAIN A REFERENCE TO THE SVG DOCUMENT.
  //
  // Mozilla with native SVG support and ASV running in IE both support

the
  // GetSVGDocument interface for the <embed> object.
  //
  //   http://w3.org/TR/SVG11/struct.html#InterfaceGetSVGDocument
  //
  // Unfortunately ASV in IE doesn't allow us to check if the method
  // getSVGDocument() exists without calling it. Since calling a
function that
  // doesn't exist will cause an error we must be prepared to catch an
  // exception.


  var embed = document.getElementById('em');
  try {


    svgdoc = embed.getSVGDocument();
  }
  catch(exception) {
    alert('The GetSVGDocument interface is not supported');
  }


  // If the GetSVGDocument interface is supported then the global
variable
  // svgdoc will now contain a reference to the SVG document. Otherwise

it will
  // be null.
  //
  // NOW WE TRY TO OBTAIN A REFERENCE TO THE SVG DOCUMENT'S "window"
OBJECT.
  //
  // The W3C does not provide a direct way to obtain the "window"
object for
  // the SVG document from the <embed> element (obviously, since it's
not a W3C
  // tag). The W3C way to access the SVG document's "window" object is
via the
  // SVG document itself, using the defaultView attribute of the
DocumentView
  // interface.
  //
  //
http://www.w3.org/TR/DOM-Level-2-Views/views.html#Views-DocumentView
  //
  // ASV in IE doesn't implement the W3C's DocumentView interface
(yet), so we
  // also try to access the SVG document's "window" object using the
non-W3C
  // standard properties 'window' and non-W3C standard function
getWindow() on
  // the <embed> object. Again ASV doesn't allow us to check whether
getWindow()
  // is supported, so we need to be ready to catch an exception if
calling it
  // causes an error.


  if (svgdoc &amp;&amp; svgdoc.defaultView)  // try the W3C standard
way first
    svgwin = svgdoc.defaultView;
  else if (embed.window)
    svgwin = embed.window;
  else try {
    svgdoc = embed.getWindow();
  }
  catch(exception) {
    alert('The DocumentView interface is not supported\r\n' +
          'Non-W3C standard methods of obtaining "window" also
failed');
  }


  // If we failed to get a reference to the SVG document's "window"
then svgwin
  // will still be null.



}


</script>

<html:html lang="en">


  <html:p>
      To test JavaScript access from the HTML document to the SVG
document
      <html:a href="javascript:alert('found: ' + svgdoc)">click
here</html:a>.
      To test JavaScript access from the HTML document to the SVG
document's "window"
      <html:a href="javascript:alert('found: ' + svgwin)">click
here</html:a>
      (accessing the SVG document's "window" allows you to access
variables and
      functions defined in scripts in the SVG document).
    </html:p>


                <html:embed id="em" src="m.svg" width="500"
height="500"
type="image/xml+svg" />


</html:html>


</window>


But when I load this file I obtain:
 catch(exception) {
    alert('The DocumentView interface is not supported\r\n' +
          'Non-W3C standard methods of obtaining "window" also
failed');


How Can I do?

_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg