Friday, June 01, 2007

Capturing F1 in javascript

Developing Web applications for IE may require to custom action instead of the popup of Windows Internet Explorer Help.

OnKeyPress doesn't gets fired when pressing functional keys, however, we are able to capture F1 by inserting the following script:

<script language="javascript">
document.onhelp = function()
{
alert("help"); // instead of an alert you can define custom content
return false; // necessary for cancel original F1 event
}
</script>

Vertical alignment in DIV panel

There is no such attribute or style attribute like 'valign' or 'vertical-align' for DIV panels. And 'text-align' only sets the horizontal alignment of a DIV's content. However, if you wish to position the content vertically in the middle, you may use the 'line-height' attribute:

<div style="width: 100px; height: 100px; line-height: 100px; text-align: center; border: 1px solid red;">acontent</div>


content


Special thanks to Erika :).