By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,110 Members | 1,541 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,110 IT Pros & Developers. It's quick & easy.

JavaScript in SVG "cross compatability" with window.open

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
J Fisk wrote:
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
--
SVG - Learning By Coding
<http://svglbc.datenverdrahten.de/>
Jul 23 '05 #2

P: n/a


J Fisk wrote:
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.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #3

P: n/a
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

Martin Honnen <ma*******@yahoo.de> wrote in message news:<41********@olaf.komtel.net>...
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.

Jul 23 '05 #4

P: n/a


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/pdf...entSupport.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/in...VGViewerWindow
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.