Answer the question
In order to leave comments, you need to log in
How to download the source code of a page?
Hello, it is necessary that when the page is loaded, the code is simultaneously loaded into the JS variable, and then displayed in the code. How to do this?
Answer the question
In order to leave comments, you need to log in
The JS interpreter cannot start before the parser starts processing the code, and you will not get the source code exactly as it is. The script in respected @iiil 's example will only be able to get the re-serialized result of source code deserialization. For example, the result for IE8 for this example is:
Какой-то код
<HEAD><META content="IE=8.0000" http-equiv="X-UA-Compatible">
<META charset=UTF-8>
<META name=robots content=noindex><LINK href="http://codepen.io/iiil/pen/qtFpr" rel=canonical>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>Какой-то код</DIV><PRE></PRE>
<SCRIPT src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></SCRIPT>
the question is not entirely clear. Where will the code go into the variable?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question