[Tip] - Hiding a WordPress header using web.Execute

59 views
Skip to first unread message

Dave Smart

unread,
Mar 8, 2017, 11:16:23 AM3/8/17
to androi...@googlegroups.com
If you have a WordPress site and you want to display one of the pages in a WebView in your app but you don't want the the WordPress header and menus etc, then you can use this technique in your app to get rid of them.

function HideWpHeader()
{
    var html = "var el = document.getElementsByClassName('theme-header');"
            + "el[0].style.display = 'none'";
            
    web.Execute( html );
}

or to hide all headers and footers:-

function HideWpHeaderAndFooter()
{
    var html = "var el = document.getElementsByTagName('header'); "
       + "for(var i=0; i<el.length; i++) el[i].style='display:none;visibility:hidden';";   
    
    html += "el = document.getElementsByTagName('footer'); "
            + "for(var i=0; i<el.length; i++) el[i].style.display='none';";       
            
    web.Execute( html );
}


JAUREGUI

unread,
Mar 16, 2017, 12:45:37 PM3/16/17
to DroidScript
Hi Dave, good Tip, I've been trying your codes and work perfect, I have set up a free webpage in wordpress (like a blog), I tried to put some id in the <p > and <img> tags and I can replace them once loaded in the webview,

I tried many ways to load the text from a tag to a variable in DS but doesn't work, (using alert() inside the html text it shows the text but I can not
set it in a text variable.

My question is, Is it possible to load a text from the page to a DS variable? 

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages