Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
Hide Google Ads while printing the page

I am trying to use window.print to print a single image on my page.

That's the image user is interested to print.

Before putting ads on my website everything was working fine but after starting adsense ads while printing the page the print preview page shows the ads too.

How can i hide them ?

before i hide all the elements by css code which looks like below but now as i won't be able to know how and where an ad is placed as ad is auto.

@media print {
    @page {
        margin: 0;
        margin-top: 10px;
    }
    nav, header, .cardButtonRow, #about, .toastContainer, footer, .adsbygoogle, .google-auto-placed {
        display: none;
    }
    .cardImage img {
        width: 82%;
        box-shadow: none;
    }
} 

The page structre mostly

<body>
<nav>....</nav>
<article class="container cardContainer">


        <header>
            <h1>Your eCard is Ready to Print</h1>
            <p>Save it or Print it !</p>
        </header>

        <div class="cardImage">
            <img alt="">
        </div>

        <div class="cardButtonRow">
            <a class="button" onclick="printClick();">Print Card</a>
            <a class="button">Download</a>
        </div>

...
<footer>...</footer>
</body> 

How to print only the image ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

How about something like this:

@media print {
    @page {
        margin: 0;
        margin-top: 10px;
    }
    * {
        display: none !important;
    }
    html, body, article, .cardImage, .cardImage img {
        display: block !important;
    }
    .cardImage img {
        width: 82%;
        box-shadow: none;
    }
}

Hide everything, then un-hide the image and its ancestors.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda