The code below shows my almost complete page source (without doctype) and line number from where test() was called. Because code does not contain doctype then I when I do alert(code[line]) I don't get the right line.
<script>
function test(what)
{
var err = new Error;
var line = err.stack.split("\n")[1].split(':')[2];
var code = document.documentElement.outerHTML.split("\n");
console.log(code);
alert(line);
}
test('hello there');
<script>
How do I get 'test('hello there');' from my test function as a string?
The problem is with line numbering. My line returns the correct line number as in the source file, but my code returns page source with different numbering (it misses DOCTYPE and have different line breaks). So the question is: how to get the "real" page source?
whatbut not using it anywhere.