473,785 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting class of SVG element in Javascript

Hi,

I am working on a website that uses a SVG diagram with multiple
polygons (to represent rooms in a hotel). Each polygon has a class to
represent whether the room is single or double. In a separate
javascript file, I need to do a different action depending on the
class. How do I read the class in the Javascript file. I tried using
getAttribute("c lass"), but this does not work - IE comes up with an
error stating 'The object doesn't support this property or method'.

Any help would be greatly appreciated as this is doing my head in!!

Jacqueline
Jul 23 '05 #1
2 2849


Jacqueline Snook wrote:

I am working on a website that uses a SVG diagram with multiple
polygons (to represent rooms in a hotel). Each polygon has a class to
represent whether the room is single or double. In a separate
javascript file, I need to do a different action depending on the
class. How do I read the class in the Javascript file. I tried using
getAttribute("c lass"), but this does not work - IE comes up with an
error stating 'The object doesn't support this property or method'.


Maybe you can give some more information. What do you mean by "each
polygon has a class", do you use a CSS class attribute on the SVG
element, or are you talking about some object-oriented class you have
implemented with JavaScript?
As for your script file, is that embedded in the SVG document or in a
HTML page embedding the SVG document?
Which SVG plugin are you using with IE?
--

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

Jul 23 '05 #2
Jacqueline Snook wrote:
I am working on a website that uses a SVG diagram with multiple
polygons (to represent rooms in a hotel). Each polygon has a class to
represent whether the room is single or double. In a separate
javascript file, I need to do a different action depending on the
class. How do I read the class in the Javascript file. I tried using
getAttribute(" class"), but this does not work ...


Try this: <http://svglbc.datenver drahten.de/?code=klassen_t auschen>

cu, Thomas
--
SVG - Learning By Coding
<http://svglbc.datenver drahten.de/>
Jul 23 '05 #3

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

Similar topics

6
2437
by: Jon Slaughter | last post by:
Is there any way to get the class type from a pointer? I'm working on a class that acts as a set: I have two classes, one called FSet and the other called Element. FSet inherets Element and has an internal pointer to a list of pointer of Element type.
18
8007
by: lawrence | last post by:
If I'm pretty sure there is just one form on the page, can i do this? var myForm = document.forms; If I'm not sure about the form, is it safer to do this? if (document.forms) { var myForm = document.forms; // more code here........ }
21
3991
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
1
3533
by: Jing You | last post by:
hi every one, I have got some confused problem when I try to write some custom object by javascript. Look at the example code here: <BODY> <script language="jscript">
3
16506
by: Waffeloo | last post by:
Hi, I would like an event to trigger a change the style of all the elements that belong to some CSS class. I know it is possible to change the class of an element, for example with: <script language=javascript> function changeclass() {document.getElementById(id).className="class_id";} </script> <input type=checkbox onclick="javascript:changeclass()">
4
4605
by: chippy | last post by:
I am finding that when I use the cloneNode method to copy an HTML element that contains a <script> tag, the contents of the <script> tag, (ie. the javascript) are removed. If I do this: var form1 = document.getElementById(sID).firstChild.cloneNode(true); alert(form1.outerHTML); I can see the empty <script> tags. I am wondering if there is a reasonable workaround for this, because I need the script tag with its
2
1950
by: wilkinson.philip | last post by:
I have a javascript object which dynamically generates a table adding, deleting and moving rows as the user clicks on buttons or links. Problem is when I generate a table row and add the javascript method call to my class, I have to put the object instance name variable of the class in order for it to be called from the onclick=function(). This is seriously limiting, but I'm stuck for a way round it. Heres a edited of the code so you get...
4
2126
by: sjkothenbeutel | last post by:
I've been reading through quite a bit regarding this topic but am finding myself confused. Here is the scenario: I have a javascript class defined with methods whereas each has references to "this." As everyone is aware of, when you attach and event from an element to a class method and the class method references "this", the scope of "this" refers not to the class but rather to the element firing the event.
29
4098
by: Chris Riesbeck | last post by:
I have an image with a class and the class defines a clip rectangle. In Firefox 2 and 3, and Opera 9, I can access the rectangle with document.defaultView.getComputedStyle(). But that doesn't seem to work in Safari for Windows 3, nor when I use image.currentStyle.clip in IE 7. Is there a way to do this in those browsers? Am I doing something stupid?
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9484
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9957
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.