Mar
3
2010
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!
2 comments | tags: JavaScript, jQuery, MooTools, Web Browser, Web Development | posted in Software, Web
Feb
26
2010

Did cavemen listen to books on tape? Find out in the archives...
It’s taken some doing but all my content dating back to 2002 is now available.
Some of my most memorable moments below.
Personal
Work
no comments | posted in Personal
Feb
21
2010

Tali'Zorah knows that even in the future, corded headphones are the way to go.
I really enjoyed Mass Effect 2, so much so that I like to imagine talking to people with a choice selector near the bottom of my vision. I usually choose paragon options but I know the usefulness of a well placed renegade response. Be careful with the interrupts though!
Like many good games, I find myself drawn to the soundtrack as a way of reliving our times together. I went searching for it but unfortunately they only released it in MP3 and M4A formats so far.
Call me a snob but I think our future should be filled with upgrades and that means something better than or equal to the sound quality of a Compact Disc.
No worries though because with a bit of patience you too can…
Make your own Mass Effect 2 Soundtrack
These instructions assume you are using the PC version of the game.
- Download
- Unzip everything into a new folder.
- Copy “C:\Games\Mass Effect 2\BioGame\CookedPC\*Music.afc ” to the new folder.
- Your path may be slightly different depending on where you installed the game.
- Run “Extract, Convert.bat”
- Run “Rename.vbs”
Epilogue
Now you can enjoy 508 pieces of Ogg Vorbis encoded music while you wait for EA to release a proper Compact Disc.
Oh and special thanks to Extirpator for the original instructions on how to accomplish this.
2 comments | tags: Mass Effect, Mass Effect 2 | posted in Games, Music, Software