webview

webView之可加载JavaScript

左心房为你撑大大i 提交于 2020-02-27 22:50:21
有两个方法 方法一: 首先就是在xml文件中添加webview标签很简单不用说明 初始化控件 1 private WebView wv= (WebView) findViewById(R.id.wv); 2 private WebSettings settings = wv.getSettings(); 然后直接调用方法: 1 settings.setJavaScriptEnabled(true); 2 settings.setAppCacheEnabled(true); 3 wv.getSettings().setJavaScriptEnabled(true); 4 wv.loadUrl("需要加载的网址"); 这样就可以把需要加载页面的JavaScript添加到webview中 方法二: 首先添加内部类 1 //在webView中加载JavaScript的类 2 @SuppressWarnings("unused") 3 private final class JSInterface { 4 /** 5 * 注意这里的@JavascriptInterface注解, target是4.2以上都需要添加这个注解,否则无法调用 6 * 7 * @param text 8 */ 9 @JavascriptInterface 10 public void showToast(String

H5与Native交互之JSBridge技术

谁说胖子不能爱 提交于 2020-02-27 06:17:55
一、原理篇 下面分别介绍IOS和Android与Javascript的底层交互原理 IOS 在讲解原理之前,首先来了解下iOS的UIWebView组件,先来看一下苹果官方的介绍: You can use the UIWebView class to embed web content in your application. To do so, you simply create a UIWebView object, attach it to a window, and send it a request to load web content. You can also use this class to move back and forward in the history of webpages, and you can even set some web content properties programmatically. 上面的意思是说UIWebView是一个可加载网页的对象,它有浏览记录功能,且对加载的网页内容是可编程的。说白了UIWebView有类似浏览器的功能,我们使用可以它来打开页面,并做一些定制化的功能,如可以让js调某个方法可以取到手机的GPS信息。 但需要注意的是,Safari浏览器使用的浏览器控件和UIwebView组件并不是同一个

iOS项目之WKWebView替换UIWebView相关

笑着哭i 提交于 2020-02-27 03:58:43
在网上已经有了许多关于UIWebView替换为WKWebView的文章,所以在这里就不在多说替换的细节了,不会的可以在网上搜搜。 下面是我在项目中遇到的问题: 问题一: 在UIWebView中,网页显示(包括图片显示)比例正常,替换为WKWebView后,比例显示不正常 解决方案:直接上代码 /* 在创建WKWebView的时候,配置环境中添加下面的js语句,可以使界面自适应屏幕 */ // 自适应屏幕宽度js NSString *jSString = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);"; WKUserScript *wkUserScript = [[WKUserScript alloc] initWithSource:jSString injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES]; // 自定义配置,一般用于js调用oc方法

consistent setMember on JavaFX window

我们两清 提交于 2020-02-24 11:34:08
问题 I'm trying to use a webview in a JavaFX based UI. The content of webview has to be changed by calling its .load(...) method whenever some actions happen. after each load, I have to set some different values on the window object in webview. These values are then used in an JavaScript code which is run on ready event of document using jQuery: $(document).ready(function() { // here I use values set on window to populate/manipulate HTML elements }); I'm following Oracle's guide to get window

移动端跨平台开发框架对比分析

纵饮孤独 提交于 2020-02-23 13:13:39
前言 现在主流的移动开发平台是Android和iOS,每个平台的开发技术和运行方式都不一样,大家都是针对每个平台开发应用。自然会存在一个移动应用产品要针对每个平台开发一套的现象,这样带来的问题则是开发成本高、效率低下,进而会有进行跨平台开发的需求。从最开始以Cordova为基础的Hybrid混合开发技术,到React Native的桥接技术,到现在新兴的Flutter技术,跨平台开发技术一直在演进。 目前主流跨平台框架简介 Cordova Cordova 是Apache旗下的一个开源的移动开发框架。它允许你使用WEB开发技术(HTML5、CSS3、JavaScript)进行跨平台开发。应用在每个平台的封装器中执行,并且依赖规范的API对设备进行高效的访问,比如传感器、数据、网络状态等等。 Cordova通过对HTML、CSS、JS封装为原生APP。Cordova将不同设备的功能,按标准进行了统一封装,开发人员不需要了解设备的原生实现细节,并且提供了一组统一的JavaScript类库,以及为这些类库所使用的设备相关的原生后台代码。因此实现了“write once, run anywhere”(一次开发,随处运行)。 Cordova前身是PhoneGap。2011年Adobe公司将其收购对其开源,并捐献给Apache,重新命名为Cordova。 React Native React

How to reload webview in Flutter?

倖福魔咒の 提交于 2020-02-23 06:55:13
问题 In a Flutter app, I would like to reload the Webview page when I press the refresh icon button on the appbar. I am using the official webview_flutter and do not want to use the flutter_webview_plugin as I have a side drawer. Any ideas as to how to refresh the webview page? I've tried using setState() to rebuild the same page but the app doesn't rebuild itself. I've also tried using navigator.push() but this directs to a fullscreen webview and covers the drawer and appbar. Widget build

How to hide/show Bottom Navigation View during webview Scroll

对着背影说爱祢 提交于 2020-02-22 17:07:24
问题 i have a BottomNavigationView activity . in that i placed a webview as fragment , but the problem is ,user can not click on the web contents on the bottom side, because of my BottomNavigationView , is there any one to suggest me a good solution this is my activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id

How to hide/show Bottom Navigation View during webview Scroll

北城以北 提交于 2020-02-22 17:03:27
问题 i have a BottomNavigationView activity . in that i placed a webview as fragment , but the problem is ,user can not click on the web contents on the bottom side, because of my BottomNavigationView , is there any one to suggest me a good solution this is my activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id

Proguard.cfg 配置

瘦欲@ 提交于 2020-02-22 13:52:08
-optimizationpasses 5 //代码混淆压缩比 默认为5 一般不需要改 -dontusemixedcaseclassnames //混淆后的类名为小写 如public class a -dontskipnonpubliclibraryclasses //混淆第三方 库 加上此句后 可再后面配置某些库不混淆 -dontpreverify // 混淆前认证,可去掉加快混淆速度 -verbose //混淆的log 帮助排错 -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* //代码混淆采用的算法,一般不改变,用谷歌推荐算即可 -keepattributes *Annotation* 假如项目中有用到注解 应用加入 引用外部的jar包 如果不是自己写的 最好不混淆它们,因为外部jar包有可能已经混淆过,根据实际情况来 不混淆某些外部jar 保持外部jar包不变的方法-dontwarn android.support.v4.** //执行下面一行代码如果有警告也不用中止,因为此jar不是我们自己写的,有警告也不处理,故dontwarn-keep class android.support.v4.** //项目中用到此jar包,在打包时必须不混淆

How to load local directory inside iframe in iOS Swift?

∥☆過路亽.° 提交于 2020-02-16 10:40:11
问题 In loadHTMLStringImage function i have been loaded index.html let htmlPath = Bundle.main.path(forResource: "index", ofType: "html") let htmlUrl = URL(fileURLWithPath: htmlPath!, isDirectory: false) self.webView.loadFileURL(htmlUrl, allowingReadAccessTo: htmlUrl) After loading I have been checking md5 string. From the md5 zip file, I am unzipping to the local directory and got the local file directory URL. And passing the local directory URL to iframe src. But it shows an empty screen. In