2012-05-17 17 views

risposta

0

@Pointy dice che questo non è possibile a causa misura di sicurezza del browser.

10

In effetti si può avvolgere utilizzando il seguente codice:

final Context myApp=this; 

    webView.setWebChromeClient(new WebChromeClient(){ 
    @Override 
    public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result) 
    { 
     new AlertDialog.Builder(myApp) 
     .setTitle("Simmon says...") 
     .setMessage(message) 
     .setPositiveButton(android.R.string.ok, 
       new AlertDialog.OnClickListener() 
     { 
      public void onClick(DialogInterface dialog, int wicht) 
      { 
       result.confirm(); 
      } 
     }).setCancelable(false) 
     .create() 
     .show(); 
     return true; 
    }; 
    }); 

Codice sorgente here

gl

+0

Non so perché, ma questo metodo è ignorato nella mia app. –

+0

ha funzionato per me con copia e incolla in 'onCreate()' – Lightbeard

0

Sì, è possibile, ho fatto

webview.setWebChromeClient(new WebChromeClient() { 




     public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result) 
     { 
      new AlertDialog.Builder(activity) 
      .setTitle("Calendário App...") 
      .setMessage(message) 
      .setPositiveButton(android.R.string.ok, 
        new AlertDialog.OnClickListener() 
      { 
       public void onClick(DialogInterface dialog, int wicht) 
       { 
        result.confirm(); 
       } 
      }).setCancelable(false) 
      .create() 
      .show(); 
      return true; 
     }; 
      }); 
+1

Non so perché, ma questo metodo viene anche ignorato nella mia app. –

+1

@ LuisA.Florit A mio parere, forse è stato suJsComfirm ottenere chiamato invece di onJsAlert. – ohyes

Problemi correlati