WP8中的WebBrowser控件中的ContextMenu(OnMSGestureHold而不是OnContextMenu(WP7)) [英] ContextMenu in WebBrowser control in WP8 (OnMSGestureHold instead of OnContextMenu (WP7))
本文介绍了WP8中的WebBrowser控件中的ContextMenu(OnMSGestureHold而不是OnContextMenu(WP7))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在WP8中向WebBrowser控件添加ContextMenu?
How can you add a ContextMenu to a WebBrowser control in WP8?
在WP7中,它使用了以下代码:
In WP7 it has worked with this code:
public void AttachContextMenu()
{
if (webBrowser.IsScriptEnabled)
{
webBrowser.InvokeScript("execScript", "function HandleContextMenu() \r\n{\r\n\twindow.external.notify('TEST');\r\n}");
//WP7:
webBrowser.InvokeScript("execScript", "document.oncontextmenu = HandleContextMenu;");
//WP8:
//webBrowser.InvokeScript("execScript", "document.onmsgesturehold = HandleContextMenu;");
}
}
private void webBrowser_ScriptNotify(object sender, NotifyEventArgs e)
{
MessageBox.Show(e.Value.ToString()); //Show Message "TEST"
}
private void webBrowser_LoadCompleted(object sender, NavigationEventArgs e)
{
AttachContextMenu();
}
在下面的文件中说明一个应该使用 OnMSGestureHold 而不是 OnContextMenu。
In the following document it is stated that one should use OnMSGestureHold instead of OnContextMenu.
http://msdn.microsoft.com/en-us/library /windowsphone/develop/jj206947(v=vs.105).aspx
http://msdn.microsoft.com/en-us/library/ie/hh771894(v = vs.85).aspx
但这不起作用。不调用事件处理程序( HandleContextMenu )。
But that does not work. The event handler (HandleContextMenu) is not called.
有人能帮我吗?谢谢!
推荐答案
你在设置:
Are you setting:
Browser.IsScriptEnabled = true;
-Jeff
这篇关于WP8中的WebBrowser控件中的ContextMenu(OnMSGestureHold而不是OnContextMenu(WP7))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文