• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Walking the DOM tree

 
Ranch Hand
Posts: 52
1
MySQL Database Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because IE and Firefox have different DOM standards
I ideally would like to walk the DOM so I could see what Nodes existed
and then I would like to see what properties were available in each node
Does anybody know of any tools or methods to do this?
----------------------------------------------------------------------
What Do I actually want to achieve?
<a href="#" id="Buy" name="Buy">Buy</a>
in IE 8 this href element can be identified by
TheEvent.srcElement.id (Where "TheEvent" represents a mouseover of this link and TheEvent.srcElement.id ="Buy")
in Firefox 3.5.2
TheEvent.srcElement.id Is invalid and I get nothing and I don't know how to address this node

Can anyone please help?
Thanks Stephen Black

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Event instances have nothing to do with DOM nodes. So "walking" the DOM won't help you out one bit.

And yes, inexplicably, unconscionably, and annoyingly, IE still does not support the standard event model and insists on doing things its own proprietary way.

You can divine the properties of an object using the for-in construct of JavaScript.

You can also save yourself a ton of headaches and adopt the use of a library like jQuery to federate event handling to a browser-agnostic API.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And as Eric (with the fastest Return key on the face of the planet) has shown, cross-browser event handling means making conditional checks at each and every turn.

How to get the Event instance? Different.

The properties of the Event instance? Different.

How to control propagation and default actions? Different.

Is it a wonder I have no hair!?!

Save your hair and look into jQuery. You'll thank me (and Eric -- he'll endorse it too).
 
Stephen Black
Ranch Hand
Posts: 52
1
MySQL Database Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
New Idea
Actually stuff this making conditional checks at each and every turn
Why don't I just get PHP to detect the brower and serve up an IE page
for the IE users and a Firefox page for the Firefox users?
I think the only drawbacks are
1. Extra work for the server
2. You now have 2 scripts to edit (but they are both easier to edit)
-
Now I am going to look at the "for-in" construrct (which I have never used)
and I am going to research more (google) about the JQuery library
before I ask any more questions
Thanks All
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Bear Bibeault wrote:
And as Eric (with the fastest Return key on the face of the planet) has shown, cross-browser event handling means making conditional checks at each and every turn.

How to get the Event instance? Different.

The properties of the Event instance? Different.

How to control propagation and default actions? Different.

Is it a wonder I have no hair!?!

Save your hair and look into jQuery. You'll thank me (and Eric -- he'll endorse it too).

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephen Black wrote:Why don't I just get PHP to detect the brower and serve up an IE page
for the IE users and a Firefox page for the Firefox users?


How 1998. Do you really want to maintain separate pages for each browser?

What's your beef with stepping into the 21st century and employing one of the modern JavaScript libraries as recommended?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Detecting with user agent is a very.bad idea. People change their user agent strings and you will serve them wrong things. Plus IE6,7,&8 support
different things so it is more than 1 file. Plus I have hacks that let my IE7 run as 6. Fun. Stuff.

Eric
 
Stephen Black
Ranch Hand
Posts: 52
1
MySQL Database Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought it was a good idea at the time but it's good that I know it's a bad idea
I might just step into the 21st century and use a modern JavaScript library as recommended
--------------------------------------------------------------------------------------------------------------------------------------

Bear Bibeault wrote:

Stephen Black wrote:Why don't I just get PHP to detect the brower and serve up an IE page
for the IE users and a Firefox page for the Firefox users?


How 1998. Do you really want to maintain separate pages for each browser?

What's your beef with stepping into the 21st century and employing one of the modern JavaScript libraries as recommended?

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We're good at this!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic