gpt4 book ai didi

javascript - 修改 alert() 标题(Android Webview 中的 Javascript)

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:59:02 28 4
gpt4 key购买 nike

截图:The page at file://

有没有办法修改警告框的标题?任何帮助将不胜感激。 :)

最佳答案

事实上,您可以使用以下代码将其包围起来:

    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;
};
});

代码源here

gl

关于javascript - 修改 alert() 标题(Android Webview 中的 Javascript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10635563/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com