By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,181 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

2 ways to call even-what is the difference?

P: n/a
Hi All
I wanted to know what is the difference between:

1.getting an object

the first worked for me and the other didn't
var Subform = document.getElementById("Items2");

var Subform =document.all("Items2")

2.I was tryng to do attachedEvent, again the first one worked and the
other didn't, I would like to understand why.
I didn't get any error jus didn't work

var Subform = document.getElementById("Items2");
Subform.onreadystatechange = function() {setIPandDetach
(event.srcElement,currentRowID)} ;
var Subform =document.all("Items2")
document.all("Subform").attachEvent("onreadystatec hange", function()
{setIPandDetach (event.srcElement,currentRowID)}

thanks!
Aug 6 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Montezuma's Daughter" <Ur*********@gmail.comwrites:
I wanted to know what is the difference between:

1.getting an object

the first worked for me and the other didn't
var Subform = document.getElementById("Items2");

var Subform =document.all("Items2")
In which browser?

The former is the W3C DOM standard method for finding an element
by its id. It works in all modern browsers and in IE 5+.

The latter is the Microsoft proprietary method for finding an
element by its id (or name). It works in IE 4, and most new browsers
emulate the document.all collection - at least if you use it as
document.all["Items2"]
instead of as a function.

Use the former, but if document.getElementById doesn't exist, you
might want to fallback to document.all (if that exists).
2.I was tryng to do attachedEvent, again the first one worked and the
other didn't, I would like to understand why.
I didn't get any error jus didn't work

var Subform = document.getElementById("Items2");
Subform.onreadystatechange = function() {setIPandDetach
(event.srcElement,currentRowID)} ;
This probably only worked in IE anyway. The "event" variable
is global in IE, but is passed as argument to the handler function
in most other browsers.
var Subform =document.all("Items2")
document.all("Subform").attachEvent("onreadystatec hange", function()
{setIPandDetach (event.srcElement,currentRowID)}
Do you mean to do 'document.all("Subform")'?
Why not just "Subform.attachEvent(...)"?

Your code is IE specific and won't work well, if at all, in most other
browsers.

/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Aug 6 '08 #2

P: n/a
On Aug 5, 10:03*pm, Lasse Reichstein Nielsen <l...@hotpop.comwrote:
"Montezuma's Daughter" <Urania.m...@gmail.comwrites:
I wanted to know what is the difference between:
1.getting an object
the first worked for me and the other didn't
var Subform = document.getElementById("Items2");
var Subform =document.all("Items2")

In which browser?

The former is the W3C DOM standard method for finding an element
by its id. It works in all modern browsers and in IE 5+.
Well, sort of. getElementById is still buggy in IE8.

http://www.gtalbot.org/BrowserBugsSe...ersusName.html

Garrett
>
/L
Aug 6 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.