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
Post a Comment