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

186
Visualizações
Higher priority of dialogues window than DOM elements

I've got a strange problem with displaying elements on page in a good order. I want to show at the begining document.write with welcome, then ask for a name with prompt and at the end show the result on the page. Somehow before anything shows a prompt is displaying. Why is this happening? This is for a school purpose :)

document.write(`Hello `);
const text = prompt(`what's your name?`);
document.write(`${text}, nice to meet you :)`);

If something is unclear, feel free to ask :)

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

0

As discussed in the comments, this works differently in different browsers and I suspect that is due to how browsers go about their rendering cycles.

It goes beyond document.write, if you try to append an element to the document you will observe the exact same behavior.

I tried to force chrome to render in-between the write/append calls but it sturdily refused to. I'm guessing this is some kind of supposed optimization on their side, not sure, but if you really insist on doing that you'll have to employ an additional context, and that will not work with document.write as it will overwrite whatever is already in the document.

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