473,324 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Question about some basic functions in SVG ECMAScript

RC
Sorry I couldn't find appropriate group for
SVG and ECMAScript. Since SVG is in XML format
and ECMAScript is very similar to JavaScript.
What's why I post in these two groups.

In the O'Reilly SVG book, in chapter 11
Animating and Scripting SVG. It mentions
some very basic functions like

var circle = event.getTarget();

var obj = svgDocument.getElementById("idName");

I got error message said these are no a function
in Firefox and batik-squiggle.jar

When I used SVGView plug-in (made by Adobe) for IE .

I typed:

var svgObject = evt.target;
var svgDoc = svgObject.getOwnerDocument();
var svgElement = svgDoc.getElementById(idName);
var svgStyle = svgElement.getStyle();
svgStyle.setProperty('stroke-width', 3);

These lines are working fine for SVGViwe Plug-in by
not work for Firefox and batik.
They complained that getOwnerDocument is not a function.
I tried to change getSVGDocument but no luck.

Is that O'Reilly book too old? Its first editoin is 2002.

How can I make getElementById() working in Firefox and Batik?
Is there some examles or some documents?
Thank Q very much in advance!
Jun 14 '06 #1
1 1660


RC wrote:
var circle = event.getTarget();

var obj = svgDocument.getElementById("idName"); var svgObject = evt.target;
var svgDoc = svgObject.getOwnerDocument();
var svgElement = svgDoc.getElementById(idName);
var svgStyle = svgElement.getStyle();
svgStyle.setProperty('stroke-width', 3);


The ECMAScript binding for the DOM want you to use e.g.
event.target
svgObject.ownerDocument
svgElement.style
and not those getXXX variants you are using.
With the Adobe SVG viewer you can use both variants but for newer SVG
implementations you need the variants I have outlined above.
See also
<http://jwatt.org/svg/authoring/#asv-getters-and-setters>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Casper Bang | last post by:
My question is fundamental I beleive but it has been teasing me for a while: I have two classes in my app. The first class is instantiated as a member of my second class. Within this first class,...
10
by: Boobie | last post by:
var myString = new String("Hello world") ; var myString = "Hello world" ; There is NO difference between the two right ? both creates a String obj right ?
55
by: Steve Jorgensen | last post by:
In a recent thread, RKC (correctly, I believe), took issue with my use of multiple parameters in a Property Let procedure to pass dimensional arguments on the basis that, although it works, it's...
21
by: yeti349 | last post by:
Hi, I'm using the following code to retrieve data from an xml file and populate a javascript array. The data is then displayed in html table form. I would like to then be able to sort by each...
15
by: Sam Kong | last post by:
Hello! I got recently intrigued with JavaScript's prototype-based object-orientation. However, I still don't understand the mechanism clearly. What's the difference between the following...
1
by: RC | last post by:
Sorry I couldn't find appropriate group for SVG and ECMAScript. Since SVG is in XML format and ECMAScript is very similar to JavaScript. What's why I post in these two groups. In the O'Reilly...
14
by: ablock | last post by:
I have an array to which i have a added a method called contains. I would like to transverse this array using for...in...I understand fully that for...in is really meant for Objects and not Arrays,...
22
by: sheldonlg | last post by:
I am looking for a clean solution to a problem that I solved in, what I call, a "dirty" way. Here is what I want to do. I have a dropdown list. Clicking on an item in the dropdown list invokes...
16
by: =?Utf-8?B?cmJEZXZlbG9wZXI=?= | last post by:
Hope this isn't too far off subject... The following was recently proposed (not by me) as a question for prospective job candidates. "Review the method below and say what gets returned."...
9
by: lorlarz | last post by:
I still have a question regarding the following code, in a commonly used routine. First, Here's the code in question: Function.prototype.bind = function(){ var fn = this, args =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.