Link not working in IE

B

Bruce A. Julseth

The following link works fine in Firefox but "Nothing" happens when I click
on the link in IE? Any idea why?

<a href="addNewPatient.php" target="_blank"><label>Add a new
patient</label></a>

Thanks..
 
M

mynameisnobodyodyssea

The following link works fine in Firefox but "Nothing" happens when I click
on the link in IE?  Any idea why?

<a href="addNewPatient.php" target="_blank"><label>Add a new
patient</label></a>

Thanks..

Remove the label tags, you can add if you want a title attribute to
the
<a> element.

Why did you use the label element inside the <a> tags?
 
H

Harlan Messinger

Bruce said:
The following link works fine in Firefox but "Nothing" happens when I click
on the link in IE? Any idea why?

<a href="addNewPatient.php" target="_blank"><label>Add a new
patient</label></a>

Anyone's ability to help you relies entirely on whether the problem
happens to lie in the small fraction of your code that you've chosen to
show us.

As it happens, it's enough to see that you've used a LABEL tag without
any indication of what it's supposed to be a label for. What was your
intention in using it?

http://www.w3.org/TR/html4/interact/forms.html#h-17.9

I'm guessing that given the choice between having your click passed on
to the handler for labels and the handler for hyperlinks, IE is choosing
to pass it on to the handler for labels. If your label were tied to a
control as it's designed to be, your click would activate or pass focus
to the control. Since there is no associated control, nothing happens at
all.
 
B

Bruce A. Julseth

Both responses, asked how I was using the label. Here is an explaination.

On the original form, I have a comboBox that loads a list of names. If the
user doesn't find the person they are looking for in the comboBox, they
click on this label to load a form "addNewPatient.php". This dialog, adds
the "new patient" to the data base, then re-calls the original form, with
the original comboBox loaded with this new person.

How would you do what I am trying to do?

All of this works fine in FireFox, but "Nothing" happens in IE. I removed
the <label> tag and it now works in IE.

Thanks..
 
M

mynameisnobodyodyssea

> How would you do what I am trying to do?

Try with the <a> element inside the <label> element, like
<label><a href="...">something</a></label>

Usually the <label> element is associated with form controls,
not with links.

I quote from the HTML 4 spec about label
To associate a label with another control implicitly,
the control element must be within the contents of the LABEL element.
In this case, the LABEL may only contain one control element.

see
http://www.w3.org/TR/REC-html40/interact/forms.html#edef-LABEL
 
B

Bruce A. Julseth

Yes, wrapping the "<a>" tag with the <label> tag also works.

Thanks...

> How would you do what I am trying to do?

Try with the <a> element inside the <label> element, like
<label><a href="...">something</a></label>

Usually the <label> element is associated with form controls,
not with links.

I quote from the HTML 4 spec about label
To associate a label with another control implicitly,
the control element must be within the contents of the LABEL element.
In this case, the LABEL may only contain one control element.

see
http://www.w3.org/TR/REC-html40/interact/forms.html#edef-LABEL
 
J

Jukka K. Korpela

Scripsit Harlan Messinger:
Anyone's ability to help you relies entirely on whether the problem
happens to lie in the small fraction of your code that you've chosen
to show us.

Not entirely. It also depends on the current state of anyone's crystal
ball and mind.
As it happens, it's enough to see that you've used a LABEL tag without
any indication of what it's supposed to be a label for.

It's also enough for seeing an interesting technical problem, though
it's not that interesting _pragmatically_. The problem vanishes in a
puff of logic, when the redundant <label> markup is removed (or <a> and
<label> are nested the other way around).

Still, we have a genuine browser bug here. No matter what sense <label>
it's valid and does not change the said:
What was your intention in using it?

An interesting question as such. Here's a case where it would make
sense:

<input type="checkbox" ... id="compr">
<a href="compr.html" title="Explanation of data compression applied">
<label for="id">Compressed</label></a>

That is, a normal combination of a field and its label, but with the
label turned into a link to a document that explains what the choice
means.

Of course, now that we know the bug, we can avoid it by nesting the
elements differently or using a different construct.
I'm guessing that given the choice between having your click passed on
to the handler for labels and the handler for hyperlinks, IE is
choosing to pass it on to the handler for labels.

Sounds plausible. Interesting enough, IE (7) lets me focus on the text
in the label (when using <a ...><label>...</label></a>), showing the
focus rectangle. It also lets me activate something by hitting Enter,
but then weird things happen. So this inaccessible in an exceptional
sense: you can work with the keyboard, but not with the mouse: normal
clicking does not work.

Or _can_ you...? Yes, you can right click on the text and open the link
via the menu.

So here we have a partial answer to the question (asked somewhere
recently) "how do I make a link non-clickable?" :) :)
If your label were
tied to a control as it's designed to be, your click would activate
or pass focus to the control. Since there is no associated control,
nothing happens at all.

I actually tried to use the construct so that the label is tied to a
control, and the control is indeed activated when the label is clicked.
E.g., if the control is a checkbox, its state is toggled.
 
G

GTalbot

Still, we have a genuine browser bug here. No matter what sense <label>
might or might make inside <a>, it's valid and does not change the
defined meaning of <a>.

Correct. This weird-looking <label> inside an <a> code may be a
variation (or a "cousin") of other label bugs:

http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/#bug118

http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/LabelForWithImage.html

happens in both IE 7 and IE 8 beta 1

An interesting question as such. Here's a case where it would make
sense:

<input type="checkbox" ... id="compr">
<a href="compr.html" title="Explanation of data compression applied">
<label for="id">Compressed</label></a>

Jukka, did you mean to code
<label for="compr">
rather? ... pretty sure that's what you meant to do there...

Regards, Gérard
 
J

Jukka K. Korpela

Scripsit GTalbot:
Jukka, did you mean to code
<label for="compr">
rather? ... pretty sure that's what you meant to do there...

Yes, surely. The <label> element is supposed to associate with the
<input> element here. I was probably thinking "the 'for' attribute needs
to contain the value of the 'id' attribute of the element it refers to",
and then my brain took the wrong path.... :-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top