P
Peter Michaux
Hi Randy,
It doesn't have semicolons at the ends of all the lines. I can't take
it! :S
Well maybe nothing wrong with it at all. In fact, it may work in more
browsers than with function literals. However it looks old and no one
bothers programming that way anymore, do they? Using the Function
constructor is leading in the direction of using eval where it is not
necessary.
I have no clue but I would guess that since the Function constructor
takes string arguments that it would parse the strings at run time and
be slower during execution than using a function literal which would be
parsed during compile time.
I don't know if the goal is to have getRef in the global space or not.
I doubt a closure is appropriate to this FAQ question so to keep it
looking simple for the FAQ maybe just this
var getRef,
dynWrite;
if (document.getElementById) {
getRef = function(id) {return document.getElementById(id);} ;
} else if (document.all) {
getRef = function(id) {return document.all(id);};
}
if (getRef) {
dynWrite = function(id, s) {getRef(id).innerHTML=s; return true;};
} else {
dynWrite = function() {return false;};
}
(Can't help it, I have to remove those uppercase function names.)
I know the repetition in defining getRef could be removed but perhaps
at the cost of clarity.
Given IE 5 has getElementById isn't it time to stop all of this
document.all stuff anyway and shove those browsers down the degredation
path with NS 4 like the current example has done. In which case the
entire example becomes
var dynWrite;
if (document.getElementById) {
dynWrite = function(id, s) {document.getElementById(id).innerHTML=s;
return true;}
} else {
dynWrite = function(){return false;}
}
This example still displays feature detection but assumes innerHTML
which is not in the character of c.l.j.
// first call to dynWrite initializes it
var dynWrite = function(id, s) {
var el;
if (document.getElementById &&
el = document.getElementById(id) &&
el.innerHTML) {
dynWrite = function(id, s) {
document.getElementById(id).innerHTML=s;
return true;
}
} else {
dynWrite = function() {return false;};
}
return dynWrite(id, s);
};
Ok maybe I've gone off the deep end but if c.l.j. regulars are going to
go on about feature detection then maybe this is the necessary version.
If lower case "random" is out then how about "chaos" or the more boring
"rand" for the function name? I really think that upper case function
names should be reserved for constructors. But hey, that's just me.
Ok. I do think they should be close so I'll try to remember this one so
I can bring it up again and make sure the nice faq volunteer isn't
bored.
I imagine this will be revisited later.
Randy, I'm not worth trusting for information yet, am I? I'm still just
the new kid.
I just downloaded four versions of NN6 and the first version to support
my test XHR test was 6.2
The Apple website says Safari 1.2 is the first with XHR
If someone took the time to determine Opera 7.6 was the first Opera
with XHR I believe them.
I don't know a thing about Ice Weasle except the name is hilarious and
I might not be able to stop laughing if I was using it. Especially if I
could see the Ice Weasle logo.
Perhaps the following would be appropriate
Mozilla (Netscape Navigator 6.2+, Firefox), Opera 7.6+, Safari 1.2+,
the Windows version of Internet Explorer 5+, and some other browsers.
Peter
What do you propose updating it to? And, what is wrong with what is
there now?
It doesn't have semicolons at the ends of all the lines. I can't take
it! :S
Well maybe nothing wrong with it at all. In fact, it may work in more
browsers than with function literals. However it looks old and no one
bothers programming that way anymore, do they? Using the Function
constructor is leading in the direction of using eval where it is not
necessary.
I have no clue but I would guess that since the Function constructor
takes string arguments that it would parse the strings at run time and
be slower during execution than using a function literal which would be
parsed during compile time.
I don't know if the goal is to have getRef in the global space or not.
I doubt a closure is appropriate to this FAQ question so to keep it
looking simple for the FAQ maybe just this
var getRef,
dynWrite;
if (document.getElementById) {
getRef = function(id) {return document.getElementById(id);} ;
} else if (document.all) {
getRef = function(id) {return document.all(id);};
}
if (getRef) {
dynWrite = function(id, s) {getRef(id).innerHTML=s; return true;};
} else {
dynWrite = function() {return false;};
}
(Can't help it, I have to remove those uppercase function names.)
I know the repetition in defining getRef could be removed but perhaps
at the cost of clarity.
Given IE 5 has getElementById isn't it time to stop all of this
document.all stuff anyway and shove those browsers down the degredation
path with NS 4 like the current example has done. In which case the
entire example becomes
var dynWrite;
if (document.getElementById) {
dynWrite = function(id, s) {document.getElementById(id).innerHTML=s;
return true;}
} else {
dynWrite = function(){return false;}
}
This example still displays feature detection but assumes innerHTML
which is not in the character of c.l.j.
// first call to dynWrite initializes it
var dynWrite = function(id, s) {
var el;
if (document.getElementById &&
el = document.getElementById(id) &&
el.innerHTML) {
dynWrite = function(id, s) {
document.getElementById(id).innerHTML=s;
return true;
}
} else {
dynWrite = function() {return false;};
}
return dynWrite(id, s);
};
Ok maybe I've gone off the deep end but if c.l.j. regulars are going to
go on about feature detection then maybe this is the necessary version.
Almost except that it uses Math.random() in the code. IIRC it was
capitalized to prevent confusion with Math.random()
If lower case "random" is out then how about "chaos" or the more boring
"rand" for the function name? I really think that upper case function
names should be reserved for constructors. But hey, that's just me.
Could sections 4.25 and 4.39 should be close together or merged?
They are closely related but different. One deals with forms with []
characters in the name while the other deals with Bracket Notation in
general. Of which I have never agreed with terming it "illegal
characters" as [] are perfectly valid in HTML attributes. The problem
comes when trying to access them via script. But, it was agreed to the
wording with regards to being illegal.
The problem with merging them is historical links in the archives. Right
now I want to try to update what is there and get it live. Then it will
be time to try to go through this again with another layout/format after
there is an updated FAQ on-line.
Ok. I do think they should be close so I'll try to remember this one so
I can bring it up again and make sure the nice faq volunteer isn't
bored.
I have always thought it should mention it. The word "preload" nor
"pre-load" appear in the FAQ anywhere and typically when people ask
about that entry they are generally wanting to know how to preload
images. Whenever a preload entry has come up someone always beckons
about "It might not work in browser KYJ so don't do it".
The last line in that entry implies that headers are the only way to
overcome that problem and I have never seen a browser where preloading
them using new Image() didn't do the trick.
Personally, I think the whole entry needs to be retitled and re-written
as a "How do I preload images" entry along with the notes/links about
headers.
I imagine this will be revisited later.
I moved the code line there to a box of it's own. Even in the old
version it starts at the end of the paragraph.
Updated, as you have it. If you can find version numbers for the first
level of each browser that supports it I can add the version numbers to it.
Randy, I'm not worth trusting for information yet, am I? I'm still just
the new kid.
I just downloaded four versions of NN6 and the first version to support
my test XHR test was 6.2
The Apple website says Safari 1.2 is the first with XHR
If someone took the time to determine Opera 7.6 was the first Opera
with XHR I believe them.
I don't know a thing about Ice Weasle except the name is hilarious and
I might not be able to stop laughing if I was using it. Especially if I
could see the Ice Weasle logo.
Perhaps the following would be appropriate
Mozilla (Netscape Navigator 6.2+, Firefox), Opera 7.6+, Safari 1.2+,
the Windows version of Internet Explorer 5+, and some other browsers.
Peter