Hello...
I have a great looking (jalert/jquery) right-click disabled dialog working but haven't been able to work it into...
"Right click popup for everyone, but allow right click on input and textarea fields"
http://www.4homepages.de/forum/index.php?topic=3088.msg12864This particular edit uses a msg box rather than the alert used initially. This msg code...
alert("© Copyright by {site_name}");
return false;
is replaced by...
msg(e);
return false;
The jalert dialog I'm using takes this form...
jAlert('Message Here', 'Title Here');return false");
When I replace the "msg(e)" and "return false", the right-click disabler is failing somehow and the context menu still pops up, but I'm not sure why. Just in case, here's what I have that does work, but without the input and text objects enabled...
{ifno is_admin}
function right(e) {
if ((document.layers || (document.getElementById && !document.all)) && (e.which == 2 || e.which == 3)) {
jAlert('Message Here', 'Title Here');
return false;
}
else if (event.button == 2 || event.button == 3) {
jAlert('Message Here', 'Title Here');
return false;
}
return true;
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = right;
}
else if (document.all && !document.getElementById){
document.onmousedown = right;
}
document.oncontextmenu = new Function("jAlert('Message Here', 'Title Here');return false");
{endifno is_admin}
:::::::: UPDATE ::::::::
Not even two minutes after all the typing above, I figured out what I was doing wrong. So, if anyone is interested, here's what worked...
{ifno is_admin}
function right(e) {
if ((document.layers || (document.getElementById && !document.all)) && (e.which == 2 || e.which == 3)) {
msg(e);
return false;
}
else if (event.button == 2 || event.button == 3) {
msg(e);
return false;
}
return true;
}
function msg(e)
{
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (target.type != "text" && target.type != "textarea" && target.type != "password")
{
//alert("© Copyright by <?=str_replace("'","\'", "{site_name}");?>");
jAlert('Message', 'Title');
return false;
}
return true;
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = right;
}
else if (document.all && !document.getElementById){
document.onmousedown = right;
}
document.oncontextmenu = msg;
{endifno is_admin}