如何在 android webview 中使用弹出窗口

2024-04-14移动开发问题
112

本文介绍了如何在 android webview 中使用弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

出于我自己的理解,我正在使用 Webview 开发类似浏览器的应用程序.

I am developing browser like application using a Webview for my own understanding.

我还不清楚如何在 android Webview 中使用弹出窗口.

I am not yet clear how to work with pop-ups in android Webview.

我遇到了 onJsAlert()onJsBeforeUnload()onJsConfirm() 等方法来处理 java 脚本弹出窗口.从这个 link 和 开发者链接

I came across these methods onJsAlert(), onJsBeforeUnload(), onJsConfirm() etc to handle java script pop ups. from this link and also developer link

当有 jsAlert 时这些工作,但我如何处理在新窗口中打开的弹出窗口?

these work when there is a jsAlert but how do i handle pop-up which opens in new window ?

我只是想知道有没有其他方法可以处理 android webview 中网站的弹出窗口,例如在新选项卡中打开或使用 webview 在新窗口中打开.

I just want to know is there is any other way to handle pop up for websites in android webview like opening in new tab or open in new window using webview.

我也无法在普通浏览器中打开在新窗口中打开的 url.如果我从 twitter 打开一些链接,则此 url 未加载,但 twitter 徽标类似于问题之一 这里

I am also having trouble to open urls which are opened in new window in normal browser.e.h If I open some link from twitter then this url is not loaded but twitter logo is seen similar to one of the questions here

这是来自普通安卓浏览器的快照,但这是作为普通页面而不是弹出页面加载到我的 webview 中的

here is the snap shot from normal android browser but this is loaded in my webview as a normal page not as pop-up

推荐答案

试试

 webViewObject.getSettings().setJavaScriptCanOpenWindowsAutomatically(true)

如果你想打开窗口......就像 window.open 一样,它是必需的.对于 javascriptenable 应该设置为 true.. 希望我理解你的请求正确.

if you want to open window...like window.open thn its required. for the javascriptenable should be set to true.. hope i understand ur quest correct.

这篇关于如何在 android webview 中使用弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何在 COCOS2d Android 中使用 CClistview?
How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)...
2024-08-12 移动开发问题
5

cocos2d-android:如何显示分数
cocos2d-android: how to display score(cocos2d-android:如何显示分数)...
2024-08-11 移动开发问题
7

Sqlite 数据库未从资产文件夹 Android 复制
Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)...
2024-04-15 移动开发问题
8

SQLite 数据库副本在由设备而不是模拟器生成时出现损坏
SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)...
2024-04-15 移动开发问题
4

安卓文件拷贝
Android file copy(安卓文件拷贝)...
2024-04-15 移动开发问题
6

Android如何在android中检测Edittext的Copy事件
Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)...
2024-04-15 移动开发问题
5