10
Jun 13

The ‘Disabled’ attribute in Internet Explorer

Given the market share that IE enjoys it is a victory for you to make your website work in IE same as chrome and other modern browsers. Development for IE is difficult and the developer tools provided by IE makes this experience awful .

Lets get to the point of this article which is to explain how the ‘disabled’ attribute works in IE . Given  below is the specification of the ‘disabled’ attribute from W3C specification.

disabled [CI]
When set for a form control, this boolean attribute disables the control for user input.
When set, the disabled attribute has the following effects on an element:

Disabled controls do not receive focus.
Disabled controls are skipped in tabbing navigation.
Disabled controls cannot be successful.
The following elements support the disabled attribute: BUTTON INPUT, OPTGROUP, OPTION, SELECT, and TEXTAREA.

This attribute is inherited but local declarations override the inherited value.

How disabled elements are rendered depends on the user agent. For example, some user agents “gray out” disabled menu
items, button labels, etc.

 

This clearly mentions that ‘disabled’ attribute only works on BUTTON INPUT, OPTGROUP, OPTION, SELECT, and TEXTAREA tags and the general policy of browser is if you use any attribute which are not authorized to use in tag then browsers neglect them but they can be accessed using javascript. But IE isn’t that kind in this case . If you apply ‘disabled’ on div tag, IE takes it seriously and makes div tag disabled . So what this means is that we not only  have any control event on div  but also according to “This attribute is inherited but local declarations override the inherited value.” rule in W3C disable specification, IE applies disabled attribute on nested elements in div tag. So be careful.

 


07
Jun 08

Page submits twice when background = “#”

If you ever come across a situation where your page goes to the same action twice for no apparent reason then make sure that there’s no background=”#” anywhere in your page.

I found that if there’s background=”#” then the page tends to submit the same request twice!! Call it a bug in html… Not sure about that. But the code is as below:

<table background=”#”>

<tr>

<td>

This piece of code in your page will cause the request to be submitted twice!!

</td>

</tr>

</table>

Please leave a comment if you have anything to add to this :)


14
Mar 08

Disable right click(Context Menu) in your HTML page

This is going to be a small post. There’s not much to talk about.

HTML has an event called “oncontextmenu”. This event handles the right click event.

So, if you want to disable right click for any field in your page, all you have to do is add “oncontextmenu” inside the particular tag. The example below will make things clear.

Ex. Suppose you want to prevent users from copy pasting something into one of your text boxes. Then you need to write the input tag as follows:

<input type=”text” oncontextmenu=”return false;”>

That’s it!! The context menu does not appear because we are handling the right click event by returning false.

Alternatively, you can disable right click for the whole page as follows:

Just copy paste the following code after the end of your <form> tag.

<script>

document.oncontextmenu = function(){return false}

</script>