You're not sending this JS command ``g_handler->SendJSCommand(g_handler->GetBrowser(), APP_BEFORE_MENUPOPUP);`` with the new code.