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

241
Visualizações
Page becomes unresponsive on clicking print button

As part of a application, I need to be able to print the contents of a div. I created a div and button to print it.

When I click on the print button I created, the page becomes unresponsive.

Does anyone know what is the problem?

button:

<a onclick="printDiv('user-table')">print</a>

script.js

    function printDiv(divName) {
        var printContents = document.getElementById(divName).innerHTML;
        var originalContents = document.body.innerHTML;

        document.body.innerHTML = printContents;

        window.print();

        document.body.innerHTML = originalContents;
    }

my print css:

@media print {
    .user-table {
        border-collapse: collapse;
        width: 100%;
        font-size: 0.9em;
        border-radius: 5px 5px 0 0;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
        table-layout: fixed;
    }

    .table .title {
        font-weight: bold;
        font-size: 18px;
        color: #1da1f2;
    }

    .user-table thead tr {
        color: #111;
        text-align: left;
        font-weight: bold;
    }

    .user-table thead tr th:first-child {
        width: 10px;
    }

    .no-print {
        display: none !important;
    }

    .user-table tr {
        border: 1px solid #ddd;
        padding: 0.35em;
    }

    .user-table th,
    .user-table td {
        padding: 12px 15px;
        text-align: center;
    }

    .user-table tbody tr {
        border-bottom: 1px solid #dddddd;
    }

    .user-table tbody tr:nth-of-type(even) {
        background-color: #f3f3f3;
    }

    .user .user-table tbody tr:last-of-type {
        border-bottom: 2px solid #1da2f2;
    }

    .user-table th {
        font-size: 0.85em;
        letter-spacing: 0.1em;
        text-transform: uppercase;
    }
}
about 4 years ago · Juan Pablo Isaza
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