Hi Edith,
The problem is with the window object.
Most viewers return the window object of the browser, some (incl. the Adobe
viewer)
return the window object of the SVG viewer, which doesn't know the .open()
method.
What you could do is test if "window.open" is available and if not, use an
alternative. You
could use a try and catch construct for that purpose. Something like:
var xlinkNS = "http://www.w3.org/1999/xlink";
var someLinks = new
Array("http://www.w3.org","http://www.svg.org/","http://
www.svgx.org","http://www.carto.net","http://www.svgopen.org");
function openWindow(url) {
var index = Math.round(Math.random()*5);
try {
//case browsers with native SVG support
(Opera9, Firefox, Apple
Webkit)
window.open(someLinks[index]);
}
catch (er) {
//case ASV, where window defaults to the ASV
window object
browserEval("window.open('"+someLinks[index]+"')");
}
}
function alternativeOpenWindow(evt,url) {
var index = Math.round(Math.random()*5);
evt.target.parentNode.setAttributeNS(xlinkNS,"href",someLinks[index]);
}
I'd prefer the second method, though, since it works around some popup blockers.
Here is the example online:
http://www.carto.net/neumann/temp/window_open.svg
Hope this helps,
Andreas
--- In [email protected], "csorba_edith" <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I would like to ask you to check whether the following function is
> correct to use in SVG:
>
> function attribute(evt) {
> var txt = evt.target.getAttributeNS(null,"id");
> var
> url="http://tsunami.geo.ed.ac.uk/local-bin/s0565608/attributeGeoglyphs.pl?
record_id="
> + txt;
> open (url);
> }
>
> Because it does not work of some reason, so I would first like to
> check whether the problem is in this function.
> It is connected to onclick event, which should take the id of the
> clicked feature and open a new window and display some attribute data
> about the clicked feature that are stored in an Oracle database. The
> id will be passed to the WHERE clause of an SQL command.
>
> Thank you.
> Csorba
>
-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/