为了节省手机流量,想在加载网页图片之前先全部加载一个本地的图片提示用户点击加载图片;有办法在Webview中实现吗?
ringa_lee2017-04-17 17:12:23
Of course, it can be achieved through the interaction between Java and js. So you need to know the relevant knowledge of js.
迷茫2017-04-17 17:12:23
You can refer to this https://github.com/pedant/safe-java-js-webview-bridge
怪我咯2017-04-17 17:12:23
This problem can be realized with WEB technology.
First there is a picture tag
<img src="placehoder.jpg" src="realSrc.jpg">
placehoder.jpg
is your local placeholder image, and src="realSrc.jpg"
saves the real URL of the image tag. placehoder.jpg
是你的本地占位图,src="realSrc.jpg"
保存的是该图片标签真实 URL。
最后就加个点击事件替换 src
src
🎜
document.addEventListener('touchstart', function(e){
var target = e.target;
if(target.tagName === 'IMG' && target.src !== target.dataset.src) {
target.src = target.dataset.src;
}
})
巴扎黑2017-04-17 17:12:23
http://bbs.deviceone.net/forum.php?mod=viewthread&tid=123&extra=page%3D1
Is this the effect?