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

254
Visualizações
In the HTML <H2> text is not appearing in the print preview google chrome browser

I am using JavaScript code for generating event click print preview, then in print preview I unable to get <H2> text, while <h1> text is appearing in the output html5 on google chrome but <H2> text is not appearing in the print preview chrome browser, Please guide and suggest me

Thanks in advance!

Input:

<?xml version="1.0" encoding="UTF-8"?>
<pat>
    <title>Main Title is Here</title>
    <body>
        <section>
            <title>section title is here</title>
            <p>Content is here</p>
        </section>
        <section><title>section title is here</title>
            <p>content is here</p>
        </section>
    </body>
</pat>

JavaScript code:

function contentWindowPrint(){
var getiframeurl = document.getElementById('contentwin');
if(location)
{
if(location.protocol == "file:")
{
printIframe(getiframeurl.src, window.iframeHeight.height);
}
else{
getiframeurl.contentWindow.window.print()
}
}
}

function printIframe(url, height) {
var heading_one = window.iframeHeight.heading
var proxyIframe = document.createElement('iframe');
var body = document.getElementsByTagName('body')[0];
body.appendChild(proxyIframe);
proxyIframe.style.width = '100%';
proxyIframe.style.height = '100%';
proxyIframe.style.display = 'none';


var contentWindow = proxyIframe.contentWindow;
contentWindow.document.open();

var is_chrome = Boolean(contentWindow.chrome);
contentWindow.document.write("<h2>" + heading_one +"</h2>")
contentWindow.document.write('<iframe src="' + url + '" onload="print();" width="1450" height="' + (height + 700) + '" frameborder="0" marginheight="0" marginwidth="0"></iframe>');
contentWindow.document.close(); // necessary for IE >= 10 and necessary before onload for chrome

if (is_chrome) {
contentWindow.onload = function() { // wait until all resources loaded 
};
}
else {
contentWindow.document.write('<iframe src="' + url + '" onload="print();" width="1450" height="' + (height + 700) + '" frameborder="0" marginheight="0" marginwidth="0"></iframe>');
contentWindow.document.close(); // necessary for IE >= 10 and necessary before onload for chrome
}

return true;
}

$(document).ready(function() {
$("div.ditasearch > input").val('')
$("div.ditasearchHeader > input").val('')
});
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