omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    WebView bug

    Pythonista
    webview pythonista pythonista3
    3
    3
    3088
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • blmacbeth
      blmacbeth last edited by

      In both the latest betas (Pythonista2 and Pythonista3) when running web_view.eval_js('alert(document.title)'), the alert is unable to be dismissed.

      Test code:

      import ui
      web_view = ui.WebView(frame=(0,0,500,500))
      web_view.present('sheet')
      web_view.load_url('https://www.google.com')
      web_view.eval_js('alert(document.title)')
      
      1 Reply Last reply Reply Quote 1
      • omz
        omz last edited by

        I see, I'm not completely sure about the best way to fix this yet, but here's a possible workaround:

        import ui
        from objc_util import ObjCInstance, on_main_thread
        
        web_view = ui.WebView(frame=(0,0,500,500))
        web_view.present('sheet')
        web_view.load_url('https://www.google.com')
        
        js = 'alert(document.title)'
        wv = ObjCInstance(web_view).subviews()[0]
        on_main_thread(wv.stringByEvaluatingJavaScriptFromString_)(js)
        
        1 Reply Last reply Reply Quote 2
        • Webmaster4o
          Webmaster4o last edited by

          I can confirm that this is still a bug on iOS 9.3 beta, where all the web dialogs were redone.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          Powered by NodeBB Forums | Contributors