Disable right clicking on images only

There are few instances where disabling someone’s context menu is appropriate. In most cases it’s unnecessary and can even lead to infuriating your visitors.

Here are some ways to target all the image elements on a page while leaving the rest of the hypertext in peace.

JavaScript

Lightweight, no framework required and works well in IE 6, 7, 8, Chrome, FireFox and Safari. Demo »

document.oncontextmenu = context_menu;

function context_menu(e) {
if (!e) var e = window.event;
	var eTarget = (window.event) ? e.srcElement : e.target;

	if (eTarget.nodeName == "IMG") {
		//context menu attempt on top of an image element
		return false;
	}
}

jQuery

Perhaps the prettiest code of the three. Demo »

$(document).ready(function(){
	$(document).bind("contextmenu",function(e){
		if(e.target.nodeName == 'IMG'){
			//context menu attempt on top of an image element
			return false;
		}
	});
});

MooTools

Moo… Demo »

window.addEvent('domready', function() {
	$(document.body).addEvent('contextmenu', function(e) {
		if(e.target.nodeName == 'IMG') {
			//context menu attempt on top of an image element
			return false;
		}
	});
});

Final Thoughts

With a bit more code you can target specific IDs, class names or any number of elemental combinations. Doing so will limit your context menu friendly fire and keep both you and your users in a happy balance.

Cheers!


Automatically backup FireFox 3 bookmarks

I like to format my computer fairly often which means having all my data in one easy to find location. Not only does this make backing up easy but it also removes that dreadful feeling you get when you realize your new OS install overwrote your irreplacable bookmarks, precious emails and/or accumulated works of Bettie Page.

Bookmarks are easily forgotten but with a few tweaks FireFox 3 can back them up for you.

Customize your bookmark backup settings

Open FireFox 3.

Go to about:config in your location bar.

Specify browser.bookmarks as your filter.

Set browser.bookmarks.autoExportHTML to true.

Create a new string titled browser.bookmarks.file and set its value to the location you want to backup all your bookmarks to.

In my case I entered “D:\ForestMist\Personal\bookmarks.html”.

firefox 3 about:config example

Restart FireFox.

Epilogue

Everytime you close FireFox it will export a fresh copy of all your bookmarks to the file you specified. There may a slight performance hit for doing this but I think the benefits far outweigh the cost.

Now you can mirror your bookmarks with services like SugarSync, share them easily with friends or just have peace of mind in case the new JSON database FireFox 3 uses behind the scenes explodes in a spectacular example of Murphy’s Law.


Catching up with FOWD New York

Future of Web Design - New York 2008

Logically, the next step after perusing through the excellent FOWA London archive was to travel forward in time and view the Future of Web Design – New York 2008 videos.

At first I felt disappointed in the ammount of materials available. After a quick check it turns out that I liked 25% of the materials vs. the 10% of really excellent talks in the previous conference. Quality vs. quantity I guess. Each are good depending on your mood. ;)

Of the New York talks, I found the following to be the most useful.

Of course, Paul Boag really steals the show here and rightly so. His presentation is jam packed with a metric butt ton of valuable insight into dealing with and educating clients.

You would think this is one of those rare once in a conference speaches but honestly, he does an amazing job on almost every time he opens his mouth. I highly recommend you take a auditory gander at the Boagworld Web Design Podcast if  you work in the web industry. Always excellent education, insightful interviews and amusing banter too. :)