Re: Script for Hiding/Un-Hiding Text On Click
- From: David Mark <dmark.cinsoft@xxxxxxxxx>
- Date: Mon, 23 Jul 2007 18:23:00 -0700
On Jul 23, 8:41 pm, Randy Webb <HikksNotAtH...@xxxxxxx> wrote:
David Mark said the following on 7/23/2007 7:16 PM:
On Jul 23, 6:16 pm, Randy Webb <HikksNotAtH...@xxxxxxx> wrote:
David Mark said the following on 7/23/2007 2:08 PM:
On Jul 23, 12:56 am, Randy Webb <HikksNotAtH...@xxxxxxx> wrote:
David Mark said the following on 7/22/2007 7:36 PM:
On Jul 22, 6:37 pm, Randy Webb <HikksNotAtH...@xxxxxxx> wrote:
David Mark said the following on 7/22/2007 6:20 PM:
On Jul 21, 8:18 pm, ASM <stephanemoriaux.NoAd...@xxxxxxxxxxxxxxxxxx>
wrote:
<snip>
Sure there is. See my code at the bottom.Yep.Again, you missed the point. You don't want that CSS written if:Not true. If document.getElementById is not supported then you don't<html>That is a preposterously inept test. I would think that a test for the
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FAQ</title>
<script type="text/javascript">
if (document.getElementById) document.write('<style type="text/
css">#questions dd {display:none}<\/style>');
want to write this style. See below.
a) You can't get a reference to the element (getElementById)
b) You can't change the style property of that element.There's no reliable way to know that. So nobody tests for that. Name
one browser that supports getElementById, but cannot change style
properties.
You are thinking backwards. Your attitude is "Until someone names one, INot even the supposition that gEBI is present and that the styleAgain, name one agent. Just one. Alternatively, post a code example
property is present will assure you that you can change it.
that tests for this occasion.
don't have to worry about it". Mine is, if I code against that
possibility, I don't have to worry about it. One is a flawed attitude to
have.
No, I don't think you have a clue what my attitude is. I simply left
the further improvement of the example as an exercise. Do whatever
you want with it.
Your coding style - and the defense of it - says a lot about your
attitude about browser scripting. And the lack in your abilities of
successfully doing so.
Since you haven't posted any code at all, except for a botched re-hash
of mine, I don't think you have much to say on this subject.
<snip>
I hope your "libraries" aren't riddled with that thought process. IfThere just aren't any agents out there that support one and not theAnd you think that is a better position than testing for it and notNo test here to see if the browser supports gEBI or not?What browser supports getElementById, but not getElementsByTagName?
if (el) {What makes you sure the browser supports getElementsByTagName?
var links = el.getElementsByTagName('a');
If you can come up with one, then there should be two feature tests
before writing the style and attaching the onload handler.
caring if a browser doesn't support it? One way the browser silently
degrades, the other way it doesn't - it throws an error. Which is more
user friendly?
other. But it isn't hard to add a test for getElementsByClassName if
you are worried about that. I'll leave that as an exercise.
they are, then it is a good thing we haven't seen any of them.
What "libraries?" I think I mentioned one specific library in another
thread. Is that what you are talking about? If so, your hopes about
it are not of any concern as you don't use XHTML. I don't see how it
is either good or bad that you (and the mouse in your pocket) haven't
seen it.
It is your claim - in that "other thread" - that your code works
flawlessly whether the browser interprets the code as HTML or XHTML so
Applications I have written for both are working for both. What does
that have to do with this thread?
your claim that I don't use XHMTL (which is wrong in itself) is no
defense at all. Does your local college offer a class in public debate?
Defense of what?
If so, you should take it as you suck at it.
Never you mind what I should take.
No, the test is moronic whether it is duplicated or not. The styleThere you go again. That test makes no sense on its own. But pairedOK, it isn't. Make you feel better? Whether I think it is or not, I<snip>Preferable is relative.
So no, your code doesn't come close to being a "preferable" solution. It
may be better than what was posted.....See the previous sentence. And by "may be", I assume you did compare
it to the previous post. So what exactly are you saying? Other than
the point about detecting getElementById, what would you suggest to
improve it?
I didn't claim the previous post was perfection. But tell me this
isn't:
simply said it because you wanted me to. But no, it isn't. Not even
close because you still haven't realized the problem with this testing:
<snip>
if (document.getElementById) document.write('<style type="text/
css">#questions dd {display:none}<\/style>');
with the identical test a few lines down, it makes perfect sense.
Either you don't get it or you are trying to turn this discussion into
a personal attack. I don't really care either way as I am about ready
to stop reading your posts entirely.
It has nothing to do with being personal or not, the test for
document.getElementById is moronic if you think it satisfies the
requirement for knowing whether to write the style block or not.
You still don't get that do you?
element isn't even needed in the page at all for a modern browser. Even
What in God's name are you babbling about now? The style element
isn't needed for a modern browser? What does that mean?
It means precisely what I wrote. Can you not read plain English? The
style element doesn't have to be written for a "modern browser". Any of
the modern browsers don't need it there in order to manipulate the styles.
Which has nothing at all to do with why I wrote it.
if it is (I think IE6 didn't like manipulating styles that weren't
defined)
You think wrong.
Ok. I didn't really care at the time as it was irrelevant to me.
So it is okay to post nonsense as long as it isn't relevant to you?
it would be hard coded as display: block. See below.
Hard coded? display: block? That's the default!
You really are as inept as I thought you were. It may have been IE5.0,
IE5.5 I don't remember but it wouldn't allow you to modify a style if it
was not hard coded into the page. The way the code I wrote is written if
the browser couldn't modify it without it being hard coded then you
would have to hard code it. And to be able to - successfully -
This is "plain English?"
manipulate it then you would hard code it and the only way to hard code
it to make it gracefully degrade would be to code it as display: block.
Which you didn't do in your example. Yes, this is all quite clear.
The fact that you know nothing about that speaks volumes.
You are very hard to follow.
<snip>
It is? You get brownie points if you can correctly answer the lastI don't have to re-read anything. You just keep repeating the sameif (document.getElementById) window.onload = windowLoadThat test - once again - is fatally flawed. Reread the post to figure
out why.
thing as if I don't understand and that is a silly thing to do.
No, this isn't my first rodeo.Odd that at the end of the day, you haven't posted a single line of
code. Where's the "if styles can be changed" feature test? It
obviously is just a theoretical waste of time.
question in this code:
You seem to be confused. Lets see how you did on your assignment to
improve my code. By the way, it took you long enough to complete.
The only one confused on how to write cross-browser degrading code is
you. Also, it was not an "assignment" (I will leave those for your
instructor to give you), it was proof of concept to show you how inept
you are at what you claim to do for a living.
LOL. I never claimed anything about what I do for a living. Cite one
post. Inept is thinking that the length of "000" is 1. Want me to
cite that one, professor? I suspect you are still smarting from it
and that explains your attitude.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FAQ</title>
<script type="text/javascript">
function showAnswer() {
var id = this.id;
var el = document.getElementById('a' + id.substring(1));
if (el) el.style.display = (el.style.display == 'block')?'none':'block';
return false}
function windowLoad() {
var el = document.getElementById('questions')
if (el &&
el.getElementsByTagName &&
el.getElementsByTagName('a') &&
el.getElementsByTagName('dd') )
{
var links = el.getElementsByTagName('a');
var answers = el.getElementsByTagName('dd')
for (var i = links.length - 1; i >= 0; i--)
{
links[i].onclick = showAnswer;
links[i].href = '#';
If you are going to copy my code, at least copy the last version
posted.
I didn't copy "code", I copied some garbage text and modified it. There
is a difference but I doubt you would understand the difference.
links[i].tabIndex = 0;
if (answers[i].style)
{
answers[i].style.display = "none";
This is hardly an improvement. What you've done is make the answers
flash for a second during the page load. Furthermore, you now have
links that don't do anything if this assignment does not update the
screen (in whatever fantasy user agent you are "defending" against.)
The difference is that mine degrades, yours doesn't.
BTW, that "fantasy user agent" you keep alluding to is my cell phone
browser that supports gEBI but does not support modifying display
properties nor does it support getElementsByClassName. I know, I know,
you can't be bothered to support such devices as you don't know how.
}
}
}}
window.onload = windowLoad
Wrong. See below.
The only person wrong here is you. You just fail to see it is all.
</script>
</head>
<body>
<dl id="questions">
<dt><a id="q1">Q. Why isn't there a style element in the source code of
this page?</a></dt>
<dd id="a1">A. It isn't needed as the styles are only set if the browser
can set it.</dd>
<dt><a id="q2">Q. What happens if the browser can't set them?</a></dt>
<dd id="a2">A. Then the answers stay visible for fallback.</dd>
<dt><a id="q3">Q. Why won't the space far activate the links?</a></dt>
<dd id="a3">A. That is a damn good question.</dd>
No it isn't. What makes you think the space bar activates links?
Because that is precisely how I have to activate links in that "Fantasy
User Agent" you don't know how to support. The lower left key (*)
activates the "Enter key" functionality. The lower right key (#)
activates the "Space Bar" functionality and the only way to activate a
link with it is the space bar. Of which it does just fine with hard
coded links, just not dynamically created links.
"Your" example creates dynamic links just like mine. Not surprising
as it is basically mine with a couple of minor modifications.
Try the enter key.
See above.
See above.
<dt><a id="q4">Q. Why is this solution better?</a></dt>
<dd id="a4">A. It degrades better than the previous version.</dd>
Degrades better for browsers that don't exist, but is far uglier for
many browsers that do exist. I don't like it.
Try again moron. The code you posted is utterly broken in the "Fantasy
User Agent" I keep telling you about but the code I posted works
flawlessly in it.
And worse in IE, Opera, etc. And why can't you name the device? I
suspect it is an old cell phone from a garage sale. Did you test with
Netscape 4 too?
<dt><a id="q5">Q. Why is there no test for gEBI on the window.onload
call?</a></dt>
<dd id="a5">A. Because whether gEBI is present or not is irrelevant
there.</dd>
You didn't test for it anywhere, which is obviously incorrect. The
very first line of windowLoad attempts to use the getElementById
method. (!)
Awww man, now I gotta get depressed, you have a point.
Yes. All of that bluster and your code has a worse flaw than mine.
<dt><a id="q6">Q. What happens if there is no display property of the
style elemnt?</a></dt>
I assume you meant "display property of the style object."
Yes.
You'll notice I didn't insult you for the obvious gaffe. You should
take a page out of my book. Nobody respects a wise-ass.
<dd id="a6">A. Then it assigns it a new property and leaves the answers
visible. Change it to "chicken" to see it fall through gracefully.</dd>
<dt><a id="q7">Q. Are there any other flaws in this code?</a></dt>
Yes. And apparently in your personality too.
The only flaw in my "personality" is that I think I can educate idiots
like you. Sue me for it.
There you go again. Sue you for what? I doubt you have anything I
would want.
<dd id="a7">A. Yes. Can you, as a "programmer" tell me what they are?</dd>
Can you as a "jackass" try to understand that this thread is not a
contest?
Is that as original a name as you can call me? I have been called worse
The most fitting. And this isn't a name-calling contest any more than
it is a coding contest.
by a lot better than you. You have mistakenly assumed it was a
"contest". It isn't. It was my failed attempt to educate you as to the
flaws in your code.
Your series of posts here seem to exist only to impress me.
Keep dreaming moron.
How many times have you used that word in this thread? You only
degrade yourself.
I'm not impressed with the noisy buildup and the "payoff" turned out
to be a flawed fizzle. What a waste of time.
Yes, but not for the reasons you think. It was a waste of time on my
part to try to educate your dumb ass. Maybe someone in the future that
reads it can learn from it as you obviously can't.
"Dumb ass", "moron", etc., etc. You are stuck in a parochial rut.
I couldn't be so lucky as to not have you read my posts though as then I
could correct your non-sense babbling without having to waste my time
trying to educate you.
In English, please.
Never mind. We're done talking here.
.
- Follow-Ups:
- References:
- Re: Script for Hiding/Un-Hiding Text On Click
- From: ASM
- Re: Script for Hiding/Un-Hiding Text On Click
- From: David Mark
- Re: Script for Hiding/Un-Hiding Text On Click
- From: Randy Webb
- Re: Script for Hiding/Un-Hiding Text On Click
- From: David Mark
- Re: Script for Hiding/Un-Hiding Text On Click
- From: Randy Webb
- Re: Script for Hiding/Un-Hiding Text On Click
- From: David Mark
- Re: Script for Hiding/Un-Hiding Text On Click
- From: Randy Webb
- Re: Script for Hiding/Un-Hiding Text On Click
- From: David Mark
- Re: Script for Hiding/Un-Hiding Text On Click
- From: Randy Webb
- Re: Script for Hiding/Un-Hiding Text On Click
- Prev by Date: Re: Solution for Floating-Point Errors
- Next by Date: Re: Solution for Floating-Point Errors
- Previous by thread: Re: Script for Hiding/Un-Hiding Text On Click
- Next by thread: Re: Script for Hiding/Un-Hiding Text On Click
- Index(es):
Relevant Pages
|
Loading