简体   繁体   中英

How to hide specific buttons in Webview while rendering HTML in react native

I am showing embedded iframe document in my application, what I am trying to do is hiding menu button from top bar in Webview and full screen button from bottom of this embedded iframe. I am using DocumentCloud platform for storing and retrieving the documents, DocumentCloud gives me the link of my document and I add that my html and rendering it using react-native-webview . This is my iframe tag link, you can open it browser. I did tried achieving this using changing fields/options in iframe src url which is probably best solution for it, but I couldn't find any option to turn that thing off in document cloud documentation. I am getting this results.

目前它正在寻找这个4

I want to hide the icons I have highlighted in above image.

iFrame looks like this

 <iframe loading="lazy" src="https://embed.documentcloud.org/documents/23488817-introductory-material-to-the-final-report-of-the-select-committee2/?embed=1&responsive=1&title=1" title="introductory-material-to-the-final-report-of-the-select-committee2 (Hosted by DocumentCloud)" width="700" height="800" sandbox="allow-scripts allow-same-origin allow-popups allow-forms allow-popups-to-escape-sandbox" frameborder="0"></iframe>

This is how I am rendering Webview.

<WebView
          scrollEnabled={false}
          onMessage={onWebMessage}
          allowsInlineMediaPlayback
          style={styles.webView}
          containerStyle={styles.webViewContainer}
          mediaPlaybackRequiresUserAction={false}
          source={{
            html: MAIN_HTML(
              iframeTag,
              viewportWidth
            ),
          }}

        />

MainHTML method is wrapping iframe tag within in html and doing some styling and reporting the height and width of iframe.

You can injectJavaScript and query these buttons with 2 selectors:

document.querySelector('.hamburger')

returns div with svg

document.querySelector('.fullscreen')

returns span with svg

Hiding is something like:

document.querySelector('.hamburger').style.display = "none";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM