private void WebViewControlWithJavaError_Loaded(object sender, RoutedEventArgs e)
        {
            var sampleHTML = @"
<html>
	<head>
		<title></title>
	</head>
	<body>
	<p><br />This is a WKWebView</p>
	<p><br />Basic alert:</p>
	<button onclick='basicAlert()'>Tap Me</button>
	<p><br />Confirmation alert:</p>
	<button onclick='confirmationAlert()'>Tap Me</button>
	<p id='confirmResult'></p>
	<p><br />Prompt alert:</p>
	<button onclick='promptAlert()'>Tap Me</button>
	<p id='promptResult'></p>
	<script>
		function basicAlert() {
            alert('Hello, World!');
		}

		function confirmationAlert() {
			var resultString;
            var result = confirm('Are you sure?');
            if (result == true) {
                resultString = 'You tapped OK!';
            } else {
                resultString = 'You tapped Cancel!';
            }
            document.getElementById('confirmResult').innerHTML = resultString;
		}

		function promptAlert() {
			var result = prompt('Enter some text','Placeholder Text');
			if (result != null) {
				document.getElementById('promptResult').innerHTML = 'You wrote: ' + result;
			}
		}
	</script>
	</body>
</html>";

            MyWebView.NavigateToString(sampleHTML);
        }
Beispiel #2
0
        /// <summary>
        /// Вызывается перед отображением этой страницы во фрейме.
        /// </summary>
        /// <param name="e">Данные события, описывающие, каким образом была достигнута эта страница.
        /// Этот параметр обычно используется для настройки страницы.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var uri   = new System.Uri("ms-appx:///" + App.CurrentWebPage + ".html", UriKind.Absolute);
            var sfile = Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);

            sfile.Completed += (w, s) =>
            {
                StorageFile file   = sfile.GetResults();
                var         reader = file.OpenReadAsync();
                reader.Completed += async(a, b) =>
                {
                    var          re = reader.GetResults();
                    StreamReader r  = new StreamReader(re.AsStreamForRead());
                    await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                    {
                        MyWebView.NavigateToString(r.ReadToEnd());
                    });
                };
            };
        }
        /// <summary>
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        /// <para>
        /// Page specific logic should be placed in event handlers for the
        /// <see cref="NavigationHelper.LoadState"/>
        /// and <see cref="NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method
        /// in addition to page state preserved during an earlier session.
        /// </para>
        /// </summary>
        /// <param name="e">Provides data for navigation methods and event
        /// handlers that cannot cancel the navigation request.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            SyndicationItem syndItemdataContext = (SyndicationItem)e.Parameter;

            this.DataContext = syndItemdataContext;
            string display = "no content";
            Uri    uri     = new Uri(syndItemdataContext.Id.ToString());

            if (display == "no content")
            {
                display = syndItemdataContext.Summary.Text;
                MyWebView.NavigateToString(display);
            }
            else if (syndItemdataContext.Id != null)
            {
                MyWebView.Navigate(uri);
            }



            this.navigationHelper.OnNavigatedTo(e);
        }