Monday, January 31, 2011

Modify right-click menu browser behavior

Recently I've discovered that it's very easy to either completely disable right-click context senstive menus or replace them with a custom dialog. While it's not normally a good idea to remove or change the right-click menu, sometimes it makes sense for a specific application. This post shows how to do it.

To disable the right click menu you need to override a handler of the 'contextmenu' event. With jQuery it's easy, for the page as a whole and for just a particular element:

To show custom menu on right click let's define it's structure and style:


Now we just have to define the 'contextmenu' event handler. It is convenient to do it right after the DOM is ready:

The second function just hides the menu if you click anywhere beyond its. The 'rclick-demo' id is the following div. So just try how it works:
to view the context menu right click here
In the end I just want to say that actually you don't have to code anything that I have done. Because there is already pretty nice jQuery plugins that can do all the work for you.
http://abeautifulsite.net/blog/2008/09/jquery-context-menu-plugin
http://www.trendskitchens.co.nz/jquery/contextmenu




Wednesday, January 26, 2011

CSS Design: Horizontal Menu

HTML unordered list (UL) is the best way to create a professional horizontal CSS menu. Here is an example:


So here you are:

Horizontal CSS menu example


Unordered list composes my menu with three elements: First, Second, Next. The 'horizontal-menu' class makes it horizontal (display: inline). Using the 'border' property gives the 'pipe look' style. Pay attention that the last-child attribute removes the pipe sign at the end of the menu. Div with the 'float: right' style puts the menu on the same line with the H4 header and aligns it to the right. Div with the clear:both style breaks the sequence of inline Div tags arranged in a single row. So the next HTML element will be placed without any floating. In my case it is just a doted line (.doted_line class) that divide menu and other part of a page.

Thursday, January 13, 2011

Howto Uninstall Powershell 1.0

When you try to install Powershell 2.0, you are prompted to uninstall other versions of Powershells before going ahead with the installation. But neither does powershell appear in Add/Remove programs nor is there an uninstall shortcut in the programs menu.

To uninstall powershell 1.0 run add/remove programs (appwiz.cpl from Win+R) and click the “show updates” checkbox. PowerShell 1.0 is installed as a hotfix (KB926139 (English installation package) / KB926140 (Localized installation package). It can be removed by clicking on remove.