本文整理汇总了C#中Windows.UI.Xaml.Controls.WebView.NavigateToString方法的典型用法代码示例。如果您正苦于以下问题:C# WebView.NavigateToString方法的具体用法?C# WebView.NavigateToString怎么用?C# WebView.NavigateToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.WebView
的用法示例。
在下文中一共展示了WebView.NavigateToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSchedule
public async Task<string> GetSchedule(string user)
{
StringBuilder sb = new StringBuilder();
try
{
UnityDataAccess uda = new UnityDataAccess();
// string sToken = await uda.GetToken(objUnityData.UnitySvcUser, objUnityData.UnitySvcPwd, user);
string strDate = DateTime.Now.ToString(@"MM/dd/yyyy");
string sJson = await uda.Magic("GetSchedule", objUnityData.UnityAppUser, objUnityData.UnityAppName, "", objUnityData.Token, strDate, "", "", "", "", "", "");
return sJson;
}
catch (Exception ex)
{
WebView wc = new WebView();
wc.NavigateToString(ex.Message);
Window.Current.Content = wc;
return "";
}
}
示例2: GetSchedule
public async Task<string> GetSchedule(string user)
{
StringBuilder sb = new StringBuilder();
try
{
string strDate = DateTime.Now.ToString(@"MM/dd/yyyy");
string sJson = await UnityDataService.Magic(UnityDataAccessActions.GetSchedule, UnityDataService.UnityAppUser, UnityDataService.UnityAppName, "", UnityDataService.Token, strDate, "", "", "", "", "", "");
return sJson;
}
catch (Exception ex)
{
WebView wc = new WebView();
wc.NavigateToString(ex.Message);
Window.Current.Content = wc;
return "";
}
}
示例3: GetUserAgent
private static Task<string> GetUserAgent()
{
var tcs = new TaskCompletionSource<string>();
WebView webView = new WebView();
string htmlFragment =
@"<html>
<head>
<script type='text/javascript'>
function GetUserAgent()
{
return navigator.userAgent;
}
</script>
</head>
</html>";
webView.NavigationCompleted += async (sender, e) =>
{
try
{
//Invoke the javascript when the html load is complete
string result = await webView.InvokeScriptAsync("GetUserAgent", null);
//Set the task result
tcs.TrySetResult(result);
}
catch (Exception ex)
{
tcs.TrySetException(ex);
}
};
//Load Html
webView.NavigateToString(htmlFragment);
return tcs.Task;
}
示例4: SetDefaultBrowserAgent
/// <summary>
/// Установить агент.
/// </summary>
/// <returns>Агент.</returns>
public async Task SetDefaultBrowserAgent()
{
var tcs = new TaskCompletionSource<string>(TaskCreationOptions.None);
var ww = new WebView();
ww.NavigateToString(@"<html>
<head>
<script type='text/javascript'>
function getUserAgent()
{
return navigator.userAgent;
}
</script>
</head>
<body>
</body>
</html>");
ww.NavigationCompleted += async (sender1, e1) =>
{
try
{
var ua = await ww.InvokeScriptAsync("getUserAgent", new string[0]);
tcs.TrySetResult(ua);
}
catch (Exception ex)
{
tcs.TrySetException(ex);
}
};
var task = tcs.Task;
var tua = await task;
BrowserUserAgent = tua;
}
示例5: ChatBoxTool
/// <summary>
/// 初始化
/// </summary>
/// <param name="wv"></param>
public ChatBoxTool(WebView wv)
{
_chat_box = wv;
_chat_box.NavigateToString(_bastChatHtml);
}
示例6: SetHtml
public static void SetHtml(WebView webView, string html)
{
webView.NavigateToString(html);
}
示例7: GetUserAgent
private void GetUserAgent()
{
// Only get user agent if running on UI thread
if (CoreWindow.GetForCurrentThread() != null)
{
var dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate()
{
// Create a new WebView and get user agent
WebView wv = new WebView();
wv.Visibility = Visibility.Collapsed;
wv.ScriptNotify += new NotifyEventHandler(UserAgentScriptNotify);
string html =
"<html><head><script type='text/javascript'>function GetUserAgent() {" +
"window.external.notify(navigator.userAgent);}" +
"</script></head>" +
"<body onload='GetUserAgent();'></body></html>";
wv.NavigateToString(html);
});
}
}
示例8: LoadWebContent
private void LoadWebContent(WebView browser, Item selectedItem)
{
#if WINDOWS_APP
if (AppSettings.MaximizeYoutubeVideos)
{
var youtubeLink = Regex.Match(selectedItem.Description, @"(https?:)?//w*\.?youtube.com/watch[^'\""<>]+").Value;
if (youtubeLink.Length > 0)
{
//Youtube videos get full screen
browser.Navigate(new Uri(youtubeLink));
return;
}
}
#endif
var bc = AppSettings.BackgroundColorOfDescription[0] == '#' ? AppSettings.BackgroundColorOfDescription : FetchBackgroundColor();
var fc = AppSettings.FontColorOfDescription[0] == '#' ? AppSettings.FontColorOfDescription : FetchFontColor();
string scriptOptions = string.Empty;
string disableHyperLinksJS = "<script type='text/javascript'>window.onload = function() { var anchors = document.getElementsByTagName(\"a\"); for (var i = 0; i < anchors.length; i++) { anchors[i].onclick = function() {return(false);}; }};</script>";
string disableOpeningHyperLinksInNewTabJS = "<script type='text/javascript'>window.onload = function() { var anchors = document.getElementsByTagName(\"a\"); for (var i = 0; i < anchors.length; i++) { anchors[i].target = \"_self\"; }};</script>";
string launchPhoneCallJS = @"<script type='text/javascript'> function callOutToCSharp(stringParameter){window.external.notify(stringParameter.toLocaleString());} window.onload = function() { var regex = /((\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4})/, replacement = '<input type=""button"" value=""$1"" onclick=""callOutToCSharp(\'launchPhoneCall:$1\');"" />'; function replaceText(el) { if (el.nodeType === 3) { if (regex.test(el.data)) { var temp_div = document.createElement('div'); temp_div.innerHTML = el.data.replace(regex, replacement); var nodes = temp_div.childNodes; while (nodes[0]) { el.parentNode.insertBefore(nodes[0],el); } el.parentNode.removeChild(el); } } else if (el.nodeType === 1) { for (var i = 0; i < el.childNodes.length; i++) { replaceText(el.childNodes[i]); } }} replaceText(document.body); } </script>";
if (AppSettings.DisableHyperLinksInItemDescriptionView)
scriptOptions = scriptOptions + disableHyperLinksJS;
if (AppSettings.DisableOpeningHyperLinksInNewTab)
scriptOptions = scriptOptions + disableOpeningHyperLinksInNewTabJS;
#if WINDOWS_PHONE_APP
if (AppSettings.EnableParsingPhoneNumbersPhone8X)
scriptOptions = scriptOptions + launchPhoneCallJS;
#endif
var webcontent = "<!doctype html><HTML>" +
"<HEAD>" +
"<meta name=\"viewport\" content=\"width=320, user-scrollable=no\" />"
+
scriptOptions
+
"<style type='text/css'>a img {border: 0;}</style>" +
"</HEAD>" +
"<BODY style=\"background-color:" + bc + ";color:" + fc + ";-ms-touch-action: pan-y;" + "\">" +
selectedItem.Description +
"</BODY>" +
"</HTML>";
browser.NavigateToString(webcontent);
}