JavaScript in SVG "cross compatability" with window.open

J

J Fisk

Hi,

I've been banging my head on the wall over this for about two days now
so any thoughts are much appreciated.

I have a static .svg file with embedded onclick="open()"'s all over.

The svg is <embed>ded in a minimal .html file.

The onclick's work fine in IE w/Adobe SVG viewer 3: click and a new
window opens with the specified URL.

But using the Adobe SVG viewer in Mozilla, neither the mouseovers or
the onclicks work, although the image itself renders.

However, the PRIMARY problem that I need to fix is that the onclick's
don't work in Safari with the Adobe viewer. The mouseovers DO work,
but the onclick's do not.

I've tried specifying window.open() instead of just open(). I've also
tried changing the onclicks to call a function openNewWindow which in
turn calls window.open. Still no luck in safari.

I've also tried defining the openNewWindow function in the html
wrapper, and specifying a3:scriptImplementation="browser". In this
case, the SVG still functions as desired in IE, but neither the
mouseovers nor the onclicks work in Safari.

To summarize, I need to get a new window with a specified URL to open
on click for Safari with the Adobe SVG viewer 3.

Thanks for any advice,

Joseph
 
T

Thomas Meinike

J said:
To summarize, I need to get a new window with a specified URL to open
on click for Safari with the Adobe SVG viewer 3.

Try top.window.open(), but AFAIK SVG vs. browser communication is only
available using (Win-)IE+ASV.

cu, Thomas
 
M

Martin Honnen

J said:
I've been banging my head on the wall over this for about two days now
so any thoughts are much appreciated.

I have a static .svg file with embedded onclick="open()"'s all over.

The svg is <embed>ded in a minimal .html file.

The onclick's work fine in IE w/Adobe SVG viewer 3: click and a new
window opens with the specified URL.

But using the Adobe SVG viewer in Mozilla, neither the mouseovers or
the onclicks work, although the image itself renders.

However, the PRIMARY problem that I need to fix is that the onclick's
don't work in Safari with the Adobe viewer. The mouseovers DO work,
but the onclick's do not.

With the following SVG example and Adobe SVG viewer 6 preview I get a
popup window opened when the circle is clicked with IE 6, Netscape 4,
and Netscape 7.1 however not with Opera 7.1:

<?xml version="1.0" encoding="UTF-8"?>
<svg
xmlns="http://www.w3.org/2000/svg"
version="1.0"
viewBox="0 0 100 100">

<script type="text/ecmascript"><![CDATA[
function openPopup (url, windowName, features) {
if (typeof browserEval != 'undefined') {
browserEval('window.open("' + url + '", "' + windowName + '", "' +
features + '");');
}
}
]]></script>

<circle cx="20" cy="20" r="10" fill="green"
title="show HTML page with relative URL"
onclick="openPopup('whatever.html', 'svgWindowTest',
'width=300,height=300,scrollbars,resizable');" />

</svg>

Please report back whether that approach (using browserEval) works with
Safari and other browsers you test with on the Mac.
 
J

J Fisk

Hi,

I used your example and it works correctly on the following
browser/platform combos:

IE/windows
IE/mac
mozilla/linux
mozilla/mac
safari/mac

So, THANK you for this help.

But, I really don't understand WHY it works. Previously, mozilla
would issue "window.open is not a function" error, but we're still
using window.open .. so what gives? I'd even tested it using
browserEval, with no luck.

Thanks very much for the help!

Joseph
 
M

Martin Honnen

J Fisk wrote:

I used your example and it works correctly on the following
browser/platform combos:

IE/windows
IE/mac
mozilla/linux
mozilla/mac
safari/mac
But, I really don't understand WHY it works. Previously, mozilla
would issue "window.open is not a function" error, but we're still
using window.open .. so what gives?

With most browsers besides IE/Win the Adobe SVG viewer 3 uses its own
scripting engine which is not able to communicate with the browser's
scripting engine besides of the browserEval function.

If you look at the viewers documentation at
http://www.adobe.com/svg/indepth/pdfs/CurrentSupport.pdf
you will see that there is no window.open method defined for the window
object of the viewer and therefore you need to use the window.open
method of the browser window object and not that of the SVG viewer
window object. With IE/Win it is possible for plugins to directly
interact with the browser's scripting engine to access the browser's
window object but in other browsers that is not possible so there all
remains is to call browserEval and construct what you want to execute.

There is also some explanation of browserEval in the SVG wiki on the page
http://www.protocol7.com/svg-wiki/index.php/AdobeSVGViewerWindow
 

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

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top