HTML text area is not refreshed as you type in Chrome.
On the page with the following code, the textbox does not update with the text I am typing until I click it. Why?
<html>
<head>
<style>
#canvas {
float: left;
}
</style>
<script>
window.onload = function() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.translate(0, 0);
}
</script>
</head>
<body>
<canvas id="canvas" width=439></canvas>
<textarea></textarea>
</body>
</html>
I found that the textbox will update correctly if I do one of the following:
- Change your canvas width to 438 or less
- Delete
ctx.translate(0,0);
- Delete
float: left;
This only happens in Chrome, I cannot reproduce it in Firefox. I am using Chrome 39.0.2171.95 and Firefox 34.0.5
+3
source to share
1 answer
This is really strange behavior. You can fix this by adding relative positioning to the textbox:
<html>
<head>
<style>
#canvas {
float: left;
}
textarea {
position: relative;
}
</style>
<script>
window.onload = function() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.translate(0, 0);
}
</script>
</head>
<body>
<canvas id="canvas" width=439></canvas>
<textarea></textarea>
</body>
</html>
+3
source to share