Reputation: 1767
On a page with the following code, the textarea doesn't update with text that I type, until I click off of 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've discovered that the textarea will update properly if I do any one of the following:
ctx.translate(0,0);
float: left;
This only happens in Chrome, I can't reproduce in Firefox. I'm running Chrome 39.0.2171.95 and Firefox 34.0.5
Upvotes: 3
Views: 582
Reputation: 35670
That is really odd behavior. You can fix it by adding relative positioning to the textarea:
<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>
Upvotes: 3