javascript - Android JsResult onJsAlert when to use confirm and when to use cancel? -


ive been running through webviewdemo andriod whereby allowing ability call native code javascript , vice-versa.

public boolean onjsalert(webview view, string url, string message, jsresult result) {         log.d(log_tag, message);         result.confirm();         return true;     } 

with regards result.confirm(), why or when call confirm or cancel?

it doesn't make difference, can call either .confirm() or .cancel() inside onjsalert. in javascript, window.alert() doesn't return value, impossible figure out in javascript, method has been called on java side. guess, jsresult used here avoid introducing dedicated class. if want able return boolean value javascript code, use window.confirm() , onjsconfirm; if want return string, use window.prompt() , onjsprompt.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -