I have a custom textbox control with extends the TextBox APS.NET class. It is built such that on right click a calendar opens. So far so good, but in Firefox the default context menu opens over my calendar control, like here:
here http://img4.imageshack.us/img4/2622/20130529135817.png . I was wondering how can I disable this Firefox content menu and prevent it from appearing.
I have tried setting in JavaScript document.oncontextmenu = function() {return false;} but this will disable all context menus on my page. My code for opening the calendar inside this control is:
if (isDate) // check if it's a date textbox where the calendar should be displayed on right click
{
this.Attributes.Add("oncontextmenu", "javascript:ShowCalendar(this);");
}
I think it I need to set it here somehow to prevent the other context menu from opening, but I am not sure how. Any advice much appreciated.
Found the solution to this. I should have called event.stop() to prevent the context menu appearing over my calendar.
this.Attributes.Add("oncontextmenu", "javascript:if(event.stop) {event.stop();} ShowCalendar(this);");
Thanks anyway!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.