javascript: urls in svg don't work




12 years ago
12 years ago


(Reporter: philipp.marek, Unassigned)


1.8 Branch
Windows XP

Firefox Tracking Flags

(Not tracked)



(1 attachment)



12 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b3) Gecko/20050716 Debian/1.0.99+deerpark-alpha2-1 Firefox/1.0+
Build Identifier: 1.5beta2

Previously SVGs were rendered using Adobe's plugin.
Some pages had SVG with URLs like "javascript:function(parm)" in them; clicking
started the javascript function.

Using firefox 1.5beta2 SVG is now handled internally, and this calls do nothing.

The svg was generated using graphviz.

Reproducible: Always

Steps to Reproduce:
1. load page with svg
2. click on element
3. nothing happens

Actual Results:  
javascript function is not called

Expected Results:  
javascript function should be called

Comment 1

12 years ago
This code works correctly for me:

<?xml version="1.0"?>
<svg viewBox="0 0 5 3" version="1.1"
  <a xlink:href="javascript:alert(5)">
    <ellipse cx="2.5" cy="1.5" rx="2" ry="1" fill="red" />

I'm using Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.9a1)
Gecko/20051010 Firefox/1.6a1.

Can you create a simple SVG file that demonstrates the bug and attach it to this


12 years ago
Assignee: nobody → general
Component: General → SVG
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → 1.8 Branch

Comment 2

12 years ago
Created attachment 199154 [details]
zip with graphviz, svg and html file

Comment 3

12 years ago
Maybe it was unintentional that it worked with Firefox 1.0, but to me it seems
that the Adobe SVG plugin just relayed the link information, whereas the newer
Firefox tries to execute it within the svg-graphic - which fails, as the
javascript is defined in the html file.
I'm afraid this is invalid Philipp. ASV is wrong to forward function calls out
to the containing HTML like that. You should be explicit if it's the function in
the containing HTML that you want to call. Add "top." to get the right scope.

Last Resolved: 12 years ago
Resolution: --- → INVALID

Comment 5

12 years ago
But if it's in some iframe in-between I have to find the correct number of

I thought that it would be marked as INVALID.
But it's a use-case that works with the "old" version (and with IE), so I
believe it's some kind of regression.
By "old version" do you mean an old version of moz with *native* SVG? If so that
would be a very bad bug. I'd want to track down when this got "fixed" and check
that there really was a fix, rather than an accidental change. If you mean ASV
in Firefox, it's ASV that was at fault.

To answer your question, you would use 'parent' instead of 'top'. To go up one
doc level:


To go up two doc levels:


Etc. Unfortunately 'parent' is broken in ASV, hence why I suggested using 'top'.
If you have to work around this you'll have to use 'top' then drill back down
towards the SVG to the doc containing the function you want to access.

Comment 7

12 years ago

So I have one more browser dependency - "old" Firefox with Adobe SVG Viewer vs.
"new" Firefox with native support.

And if the html file with the javascript and the embedded svg is in an
(a-priori) unknown depth of iframes ... AFAIK I cannot do a
"top.getElementById()" in svg, and in every case I wouldn't know how to tell
graphviz to include that.

In another web interface there is a "top.function" as URL - but that doesn't
work, too; for URLs in the initial viewport it's ok, but if I scrolls the svg
down or right a click just scrolls back to the upper-left corner, and the
javascript function isn't called.

BTW. the displayed svg look completly different from ASV; it seems to be double
the size vertical and horizontal, the given width= and height= are used (and
identical to the size within the svg), but it's displayed like with 200% zoom.
You need to log in before you can comment on or make changes to this bug.