Exemple #1
0
        public WindowsWebViewPageCS()
        {
            var webView = new Xamarin.Forms.WebView
            {
                HeightRequest = 50,
                Source        = new HtmlWebViewSource
                {
                    Html = @"<html><body><button onclick=""window.alert('Hello World from JavaScript');"">Click Me</button></body></html>"
                }
            };

            webView.On <Windows>().SetIsJavaScriptAlertEnabled(true);

            var toggleButton = new Button {
                Text = "Toggle JavaScript alert"
            };

            toggleButton.Clicked += (sender, e) => webView.On <Windows>().SetIsJavaScriptAlertEnabled(!webView.On <Windows>().IsJavaScriptAlertEnabled());

            Title   = "WebView JavaScript Alert";
            Content = new StackLayout
            {
                Margin   = new Thickness(20),
                Children = { webView, toggleButton }
            };
        }
        public AndroidWebViewPageCS()
        {
            var webView = new Xamarin.Forms.WebView {
                Source = "https://htmlpreview.github.io/?https://github.com/xamarin/xamarin-forms-samples/blob/master/UserInterface/PlatformSpecifics/HTML/mixed_content.html"
            };

            webView.On <Android>().SetMixedContentMode(MixedContentHandling.AlwaysAllow);
            Content = webView;
        }
Exemple #3
0
        public AndroidWebViewZoomPageCS()
        {
            WebView webView = new WebView
            {
                Source = "https://www.xamarin.com"
            };

            webView.On <Android>()
            .SetEnableZoomControls(true)
            .SetDisplayZoomControls(true);

            Title   = "WebView Zoom Controls";
            Content = webView;
        }