Answer the question
In order to leave comments, you need to log in
How to write the result of document.write('34'); into a variable?
The question is that I need to write the result of executing document.write('34'); into a variable, and I googled and didn't find how to do it.
document.write('34'); comes to me from the server, so I can't change it in any way.
UPD:
I understand that this is fundamentally wrong, but
var a = open("POST", "http://meteo.swamp.ru/js.php", false); <br/>
alert(a);
Answer the question
In order to leave comments, you need to log in
<script>
document.write = function(text) {
alert(text);
}
document.write('34');
</script>
You can get the result as a simple string and extract the desired part of it as a substring.
I'm not familiar with js, but as an option, redefine
document.write = function(x) {return x;}
run the response through eval:
var x = eval (response)
and return the old write to its place.
It seems to be possible to do so.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question