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

379
Visualizações
How can I extract the whole HTML of a page - before and after the DOM?

I'm trying to find a way to extract the HTML code of a web page using JavaScript in two editions:

Before the DOM / Before JS is applied After the DOM / After JS is applied

All the JavaScript methods that I know just take it from the DOM element, like document.body or document.all... but non of them work specifically for before or after the DOM.

Added: Just to focus the question further, this is not my page so I can't install any on the page, this is for any random web page.

Can you point me in the right direction? is there a specific method/command/process that is used in JavaScript and can do that? maybe I should stop the page load at specific point and take the code and then let it continue loading and take the code with the JS included?

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

0

Well, If you put a <script /> tag in the middle of your HTML your code will get executed before the continuation of the rest of your HTML.

also you can use

document.addEventListener("DOMContentLoaded", fn);

to call your function when the DOM is ready (it comes in the name of the event listener so sorry for over-explaination!)

Getting all the stuff is easy via the window object, can not imagine anything else you might need.

So if you want to do something before the DOM loads just put a <script /> tag at the top. if you want the dom to be ready use the DOMContentLoaded.

You can find great and complete documentation on this subject of script, async, defer on javascript.info. if there is anything that my explanation did not cover for you.

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