Hide header/footer when url contains a certain parameter

前端 未结 6 1694
醉话见心
醉话见心 2021-01-22 17:18

I have a multi page webpage that has a header and footer on all pages, and I am creating an app than can view certain areas of the page, but I dont want to show the footer and h

6条回答
  •  鱼传尺愫
    2021-01-22 17:52

    Here is pure Javascript, no jQuery needed

    You can do it like this (don't forget to add your URL instead of 'Your URL' in if statement):

    if(window.location.href == 'Your URL') {
      document.getElementById('header').style.display = 'none';
      document.getElementById('footer').style.display = 'none';
    }
    div {
      margin: 10px;
      width: 50px;
      height: 50px;
      background-color: green;
    }
    
    

    Cheers

提交回复
热议问题