Scripts not working in web view

Hi Team,

I have asp.net MVC website with response design, when i trying to load the website with the help of web view inside a tabbed page, it's show only content, my java scripts(JQuery) are not at all working. The same web site working charm in mobile browser.

Posts

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @Havihavi - I can't remember if scripting is turned on by default yet. You can look here: https://forums.xamarin.com/discussion/21784/xamarin-forms-webview-control-in-windows-phone-8-1-app to see if some of those renderers help you.

  • HavihaviHavihavi USMember

    He has written below line code,
    public class CustomWebViewRenderer : WebViewRenderer
    {
    protected override void OnElementChanged(ElementChangedEventArgs e)
    {
    base.OnElementChanged(e);

             if (e.OldElement == null)
           {
                var webView = (WebBrowser) Control;
                   webView.IsScriptEnabled = true;
                 }
            }
         }
    

    I am using shared code (PCL), I could not found WebViewRenderer and WebBrowser.

    Could you please help me .

    Thanks in advance

    Naresh

  • seanydaseanyda GBMember ✭✭✭✭✭
    edited January 2016

    Hi, This is a working web view renderer for Android, I believe you cannot do this in the PCL it has to be platform specific

        [assembly: Xamarin.Forms.ExportRenderer (typeof (Cpl.Xamarin.Forms.MyWebViewFullScreen), typeof (MyWebViewFullScreenRenderer))]
    
            namespace NameScape
            {
                public class MyWebViewFullScreenRenderer : WebViewRenderer
                {
                    protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
                    {
                        base.OnElementChanged(e);
                        Control.Settings.SetRenderPriority (Android.Webkit.WebSettings.RenderPriority.High);
                    }
    
Sign In or Register to comment.