Reputation: 8266
I noticed in our code that there is a disabled = ture'
i the source code for anchor tag. I was wondering why it works in IE. I also searched the internet and it is also being used in a lot of source code via a search in the net. I have been searching if ture, a wrong spelling of true can also be used by IE.
Does anybody have any idea about this?
Upvotes: 4
Views: 6050
Reputation: 801
If you're using a framework like "dojo" to render your GUI widgets the value of this HMTL markup can influence how your components render (and is different for older IE browsers). Dojo pays attention to the value of the DOM object representing the disabled attribute. For example this markup will render an enabled widget providing you are using Chrome or >=IE9:
disabled="false"
This is the opposite of how vanilla HTML components behave which will be disabled purely because the disabled attribute is present (as per Zed's post).
In Chrome and IE9/later the disabled attribute value is accurately persisted into the DOM object that represents it (for example if the attribute is not present in the markup the attribute isn't even defined on the DOM object). Since the DOM object is what drives dojo when it renders its widgets the value in the HTML markup will exert an influence.
In IE8/earlier the attribute's value is persisted into the DOM differently. Firstly the disabled attribute is always present and secondly only its absence ensures the value is false (in which case the dojo widget would appear enabled).
Note: modern IE browsers can be knobbled to regress their behaviour to older versions (such as meta tag X-UA-Compatible
with content="IE=8"
).
Example 1 vanilla html markup
As per Zed's post, only the first of these should be enabled (in any browser):
<button>OK</button>
<button disabled>OK</button>
<button disabled="false">OK</button>
<button disabled="true">OK</button>
<button disabled="mickey">OK</button>
<button disabled="">OK</button>
Example 2 dojo html markup
The first and third of these is enabled with dojo (in Chrome/IE9 or later):
<button dojoType="dijit.form.Button">OK</button>
<button dojoType="dijit.form.Button" disabled>OK</button>
<button dojoType="dijit.form.Button" disabled="false">OK</button>
<button dojoType="dijit.form.Button" disabled="true">OK</button>
<button dojoType="dijit.form.Button" disabled="mickey">OK</button>
<button dojoType="dijit.form.Button" disabled="">OK</button>
In IE8 or below the above would render exactly the same as the first example.
Strangely "" evaluates to false value in JavaScript but does not translate into a false value in the context of the above examples (and therefore an enabled widget).
Upvotes: 1
Reputation: 1
you can use this code if you want to disable it according to user level insert it inside the input form tag hope to help
<?php
if($_SESSION['user_level']=="level1")
{
?>
disabled="disabled"
<?php
}
?>
Upvotes: -1
Reputation: 943510
The disable attribute can take one value: 'disabled'
All instances of this attribute in HTML allow the quotes, separator and name to be omitted (leaving just the unquoted value).
Since browsers implement tag soup parsers and perform vast amounts of error recovery, disabled=pretty much anything will be treated as disabled
.
(And I guess that Microsoft have implemented disabled on anchors for some reason, despite the attribute not existing for that element).
Upvotes: 0
Reputation: 55072
IE is notorious for allowing error-filled HTML code to work; this is why many people mistakenly "blame" it for issues, but actually it's just they've been doing things wrong.
I believe IE allows diabled to be set to anything (other than false) to mean that it's true, because I think in the past people have written disabled='disabled'
, and other such things.
Upvotes: -1
Reputation: 57658
IE only checks for the existence of the disabled property. It's value doesn't matter.
Upvotes: 5
Reputation: 13684
It used to be that to disable an element, you just did <input type="text" disabled>
, so most browsers don't really care what goes in that attribute. I believe making it disabled="disabled"
became a standard solely so that the code would be valid XML.
Upvotes: 12