gpt4 book ai didi

javascript - 如何获取 Android WebView 中从顶部到 div block 的像素数量?

转载 作者:行者123 更新时间:2023-12-02 18:47:00 30 4
gpt4 key购买 nike

我想接收 WebView 处 div block 的位置,并使用从顶部到 div 的高度作为 View 的填充来在 WebView 上显示我的 View 。

我写了一些代码:

webView.loadUrl("javascript:{" +
" var ad = document.getElementById('iAD1');" +
" Advertisement.showAdvertising(ad.offsetTop, ad.offsetBottom);" +
" }"
);

但是该 block 在 WebView 中显示的尺寸要小一些。我不擅长 JavaScript,所以我认为我错过了一些有意义的东西或者只是使用了错误的参数。

你能告诉我如何解决这个问题吗?

最佳答案

试试这个:)它对我有用..

function detectmob() { 
if( navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
){
return true;
}
else {
return false;
}
}

关于javascript - 如何获取 Android WebView 中从顶部到 div block 的像素数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16264394/

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