473,396 Members | 1,966 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,396 software developers and data experts.

parsing DOM with Javascript, to read HTML tag info

I need to get information about certain fields in an HTML tag. "Field"
may be the incorrect term, but what I mean is the information stored in
"thing" or "widgetId" in the HTML tag below.

<div dojoType="Button" thing="foo" id="bar"
widgetId="theButton2">Grumble, grumble...</div>

I have Javascript listener in an HTML web page. On an event, a
function call in invoked, and in this function:
var curEvent = event || window.event; //either browser
var sourceEl = curEvent.tft || curEvent.srcElement; //either browser

I am interested in finding the name (in string format) of the DOM
element that generated the event. I iterate though the objects in
"sourceEl" until I find "parentElement". I am satisfied that I have
found the "parentElement" object that corresponds to the button that
generated the event, but what I cannot do from here is access the
fields in this tag. Trying to dereference the fields like
thing/id/widgetId with a dot operator only yields "undefined".

Do those those fields even exist at the time that I'm attempting to
read them?
Thanks.

Nov 8 '06 #1
1 1691
de****@gmail.com wrote:
I need to get information about certain fields in an HTML tag. "Field"
may be the incorrect term, but what I mean is the information stored in
"thing" or "widgetId" in the HTML tag below.

<div dojoType="Button" thing="foo" id="bar"
widgetId="theButton2">Grumble, grumble...</div>
These are custom attributes, if the DOM implementation exposes them then
you can get at them with getAttribute('attributeName') e.g.
var div = document.getElementById('bar');
var widgetId = div.getAttribute('widgetId');

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 9 '06 #2

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

Similar topics

9
by: RiGGa | last post by:
Hi, I want to parse a web page in Python and have it write certain values out to a mysql database. I really dont know where to start with parsing the html code ( I can work out the database...
5
by: Martin Walke | last post by:
Hi all, Can someone help me out here? I'm been using ASP and VBScript for some years but have just ventured into the realms of using server side Javascript and apart from hitting various...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
0
by: bruce | last post by:
hi... it appears that i'm running into a possible problem with mechanize/browser/python rgarding the "select_form" method. i've tried the following and get the error listed: br.select_form(nr...
2
by: hzgt9b | last post by:
I've written a simple javascript page that parses an XML file... (Actually I just modified the "Parsing an XML File" sample from http://www.w3schools.com/dom/dom_parser.asp) The page works great...
3
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a...
0
by: savj14 | last post by:
I have been driving myself crazy the past few days trying to figure this out. I have tried different Parsing Scripts and have read and searched various things trying to find a solution. I am...
1
by: Philip Semanchuk | last post by:
On Oct 12, 2008, at 5:25 AM, S.Selvam Siva wrote: Selvam, You can try to find them yourself using string parsing, but that's difficult. The closer you want to get to "perfect" at finding URLs...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.