Let's move on to take a look at another menu type—the context, or right-click menu. The navigation menu on our portfolio site provides links to three different image pages. We can use one of these pages to showcase a series of thumbnail images and add right-click functionality to each thumbnail image.
We'll take the page that we used with the Container family controls to show a full view and rate the images and replace that ugly Rate! button with a ContextMenu
with even more options.
Our custom ContextMenu
can be created entirely programmatically, without building on existing markup (except for the images of course), making the context menu very easy and quick to implement.
The following screenshot shows how the context menu should appear by the end of this example:
Add the following code to the existing <script>
block near the bottom of the page. It will create the ContextMenu
:
var context = new YAHOO.widget.ContextMenu(Dom.generateId(), ...