I have tried to get the clientWidth
value to know the width of the body. But I found a question:
Below is the original code:
<input type="text" id="width"><br/>
<input type="text" id="height">
<script>
function getScreenSize(){
document.getElementById("width").value= document.body.clientWidth;
document.getElementById("height").value= document.body.clientHeight;
}
getScreenSize();
</script>
<div style="margin-top: 5300px;">foot</div>
And when I only change getScreenSize();
into setInterval("getScreenSize()",10);
, like below:
<input type="text" id="width"><br/>
<input type="text" id="height">
<script>
function getScreenSize(){
document.getElementById("width").value= document.body.clientWidth;
document.getElementById("height").value= document.body.clientHeight;
}
setInterval("getScreenSize()",10);
</script>
<div style="margin-top: 5300px;">foot</div>
Without any reason, the value of clientWidth
changed.
Does anyone know why it changed just because I set the setInterval
function?