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

2 ways to call even-what is the difference?

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
2 1419
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Peter Ammon | last post by:
A friend was asked "How many ways are there to create an object in C++?" in an interview. Apparently, the "right" answer was eleven. Does anyone know how the interviewer arrived at that number? ...
5
by: Seong-Kook Shin | last post by:
Hi, I'm reading Steve's "C Programming FAQs" in book version, and have two question regarding to Q11.16 ... Also, a `return' from `main' cannot be expected to work if data local to main might be...
3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
7
by: J-T | last post by:
I can instantiate my object in my *ASP.NET* application in two ways: A) public sealed class RSSingleton { private static ReportingServiceProxy m_RsProxy=null; static RSSingleton() {...
17
by: Xah Lee | last post by:
if i want to have a empty link, which way is more proper? <a href=""> <a href="#"> <a href="javascript:void(0);"> Xah xah@xahlee.org ∑ http://xahlee.org/
20
by: elderic | last post by:
Hi there, are there other ways than the ones below to check for <type 'function'> in a python script? (partly inspired by wrapping Tkinter :P) def f(): print "This is f(). Godspeed!" 1.:...
26
by: momobear | last post by:
hi, I am puzzled about how to determine whether an object is initilized in one class, anyone could give me any instructions? here is an example code: class coffee: def boil(self): self.temp =...
9
by: Steve Richter | last post by:
in a generic class, can I code the class so that I can call a static method of the generic class T? In the ConvertFrom method of the generic TypeConvert class I want to write, I have a call to...
2
by: O.B. | last post by:
I have operation within a class that marshals the data into a byte array. Below are three different ways that work. Are there any downsides to using one over the the other? public virtual byte...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.