0

I'm triyng to showing twitter site on a webView. how can i remove/dismiss/invisible the header (The "open application" message)?

<header class="CoreLayout-header" role="banner"><div class=" AppHeader"><div class="OpenInAppBar u-cf" jsnamespace="OpenInAppBar"><div class="u-containerWithGutter"><a href="twitter://user?screen_name=nba" jsaction="click:openApp" class="OpenInAppBar-link u-textSmall u-inlineBlock">Open application</a><button class="OpenInAppBar-dismiss u-floatRight" aria-label="התעלם" jsaction="click:snooze" type="button"><span class="OpenInAppBar-dismissIcon u-alignMiddle Icon Icon--close" role="presentation"><img src="data:image/gif;base64,R0lGODlhFwAkAIAAAP///////yH5BAEKAAEALAAAAAAXACQAAAIbjI+py+0Po5y02ouz3rz7D4biSJbmiabqyjIFADs="><svg viewBox="0 0 46 72"><use fill="currentcolor" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/i/rw/svg/c25636093d431d0e28be32cd59239cf6/icon#icon-close"></use></svg></span></button></div></div><div class=" AppBar u-cf" data-scribe-component="top_bar" jsnamespace="AppBar"><div class="u-containerWithGutter"><h1 class="u-floatLeft"><a class="AppBar-item" aria-label="Twitter" href="/" jsaction="homeNav"><span class="AppBar-icon Icon Icon--twitter" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="><svg viewBox="0 0 72 72"><use fill="currentcolor" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/i/rw/svg/c25636093d431d0e28be32cd59239cf6/icon#icon-twitter"></use></svg></span></a></h1><div class="u-floatRight"><a class="AppBar-search AppBar-item" aria-label="חיפוש בטוויטר" href="/search" role="search" jsaction="search"><span class="AppBar-icon Icon Icon--search" role="presentation"><img src="data:image/gif;base64,R0lGODlhBwAJAIAAAP///////yH5BAEKAAEALAAAAAAHAAkAAAIHjI+py+1cAAA7"><svg viewBox="0 0 56 72"><use fill="currentcolor" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/i/rw/svg/c25636093d431d0e28be32cd59239cf6/icon#icon-search"></use></svg></span></a></div></div></div><div class=" SignUpBar"><div class="u-containerWithGutter"><div class="SignUpBar-content u-md-size3of4"><div class="Grid Grid--withGutter"><div class="Grid-cell u-size1of2"><a class="SignUpBar-button u-sizeFull Button Button--textBlue " href="/signup"><span class="Button-content">sign</span></a></div><div class="Grid-cell u-size1of2"><a class="SignUpBar-button u-sizeFull Button Button--default " href="/session/new"><span class="Button-content">Enter</span></a></div></div></div></div></div></div><div class="AppHeader-tracking"><img src="https://cert.twitter.com/robots.txt"><img src="https://twitter.com/robots.txt"></div></header> 

I'm using jsuop library but not have a clue how to remove the header.

2
  • Sorry but i not get it. Can you write me a sample code please? Commented Sep 28, 2015 at 17:10
  • Wait a minute. You only want to remove it when it's displayed on an Android device? Or only when it's in a WebView? Also, seeing the other answer, it's not clear if you want to remove the entire header (everything you posted here) or only the "Open application" link? Commented Sep 28, 2015 at 17:20

2 Answers 2

8

You could try to inject some javascript code in the onPageFinished event of the WebView, that would remove the header. Something like this:

//JavaScript must be enabled if you want it to work webview.getSettings().setJavaScriptEnabled(true); //set the WebViewClient before calling loadUrl webview.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { webview.loadUrl("javascript:(function() { " + "var head = document.getElementsByTagName('header')[0];" + "head.parentNode.removeChild(head);" + "})()"); } }); 

(code not tested)

Sign up to request clarification or add additional context in comments.

1 Comment

how can i hide footer and Image slider too ?
0

Just add style="display:none" to whatever you want hidden.

<header class="CoreLayout-header" role="banner"> <div class=" AppHeader"> <div class="OpenInAppBar u-cf" jsnamespace="OpenInAppBar"> <div class="u-containerWithGutter"> <a style="display:none" href="twitter://user?screen_name=nba" jsaction="click:openApp" class="OpenInAppBar-link u-textSmall u-inlineBlock">Open application</a> <button class="OpenInAppBar-dismiss u-floatRight" aria-label="התעלם" jsaction="click:snooze" type="button"><span class="OpenInAppBar-dismissIcon u-alignMiddle Icon Icon--close" role="presentation"><img src="data:image/gif;base64,R0lGODlhFwAkAIAAAP///////yH5BAEKAAEALAAAAAAXACQAAAIbjI+py+0Po5y02ouz3rz7D4biSJbmiabqyjIFADs="><svg viewBox="0 0 46 72"><use fill="currentcolor" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/i/rw/svg/c25636093d431d0e28be32cd59239cf6/icon#icon-close"></use></svg></span> </button> </div> </div> <div class=" AppBar u-cf" data-scribe-component="top_bar" jsnamespace="AppBar"> <div class="u-containerWithGutter"> <h1 class="u-floatLeft"><a class="AppBar-item" aria-label="Twitter" href="/" jsaction="homeNav"><span class="AppBar-icon Icon Icon--twitter" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="><svg viewBox="0 0 72 72"><use fill="currentcolor" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/i/rw/svg/c25636093d431d0e28be32cd59239cf6/icon#icon-twitter"></use></svg></span></a></h1> <div class="u-floatRight"> <a class="AppBar-search AppBar-item" aria-label="חיפוש בטוויטר" href="/search" role="search" jsaction="search"><span class="AppBar-icon Icon Icon--search" role="presentation"><img src="data:image/gif;base64,R0lGODlhBwAJAIAAAP///////yH5BAEKAAEALAAAAAAHAAkAAAIHjI+py+1cAAA7"><svg viewBox="0 0 56 72"><use fill="currentcolor" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/i/rw/svg/c25636093d431d0e28be32cd59239cf6/icon#icon-search"></use></svg></span></a> </div> </div> </div> <div class=" SignUpBar"> <div class="u-containerWithGutter"> <div class="SignUpBar-content u-md-size3of4"> <div class="Grid Grid--withGutter"> <div class="Grid-cell u-size1of2"> <a class="SignUpBar-button u-sizeFull Button Button--textBlue " href="/signup"><span class="Button-content">sign</span></a> </div> <div class="Grid-cell u-size1of2"> <a class="SignUpBar-button u-sizeFull Button Button--default " href="/session/new"><span class="Button-content">Enter</span></a> </div> </div> </div> </div> </div> </div> <div class="AppHeader-tracking"> <img src="https://cert.twitter.com/robots.txt"> <img src="https://twitter.com/robots.txt"> </div> </header>

Or, alternatively, remove it from the source completely.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.