JavaScript dot notation [duplicate]
Solution 1:
There are two ways to access properties of an object in JavaScript.
Dot notation
foo.bar.baz
Square bracket notation
foo['bar']['baz']
You are using the latter in part of your code.
Douglas Crockford, who wrote JSLint (a tool which gives that error message), is of the opinion that is is better to use dot notation where possible.
Solution 2:
JSLint wants this:
var tipobj= document.all ? document.all.dhtmltooltip
: document.getElementById
? document.getElementById("dhtmltooltip")
: "";
But nowadays is completely safe to assume that document.getElementById
exists, it was introduced on the DOM Level Core 2 as of year 2000.
document.all
is dead, unless you try to support really old browsers like IE4 (12 year old!):
var tipobj = document.getElementById("dhtmltooltip");
The two above snippets are a good example about the complexity cost of supporting very old browser versions: