在React本机WebView中禁用下载 [英] Disable download in React native WebView
本文介绍了在React本机WebView中禁用下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用程序中使用React Native WebViw.我想禁用文件下载.大多数情况下只是文件.我无法禁用存储权限,因为应用程序中的某些功能需要此功能.
I am using a React Native WebViw in my app. I want to disable download of files. Mostly just documents. I cant disable storage permissions as certain features in the app need this feature.
推荐答案
您可以通过注入JavaScript来实现此目的,并在controlsList ="nodownload"属性的帮助下检查视频文件的参考代码:
You can achieve this by injecting a javascript, with the help of controlsList="nodownload" property check below reference code for video file:
<WebView
style={{
height: this.props.videoPlayerHeight,
width: this.props.videoPlayerWidth,
backgroundColor: 'black',
}}
allowsFullscreenVideo={true}
allowFileAccess={false}
mixedContentMode="always"
mediaPlaybackRequiresUserAction={true}
injectedJavaScript={`document.getElementsByTagName("video")[0].controlsList="nodownload";`}
source={{uri: `${this.props.videoLink}#t=0.01`}}
startInLoadingState={true}
renderLoading={this.renderLoading}
/>
这篇关于在React本机WebView中禁用下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文