Closed
Bug 682819
Opened 13 years ago
Closed 13 years ago
canvas disappears if width is changed
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 680301
People
(Reporter: alberto.maccioni, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20100101 Firefox/6.0
Build ID: 20110811165603
Steps to reproduce:
A canvas element is not drawn if I change its width via javascript.
If you remove the line that sets the width then the canvas is visualized.
<html>
<head>
<script type="application/javascript">
function draw() {
if(document.getElementById('canvas').width!=document.width*0.95)
document.getElementById('canvas').width=document.width*0.95;
var canvas = document.getElementById("canvas");
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect (10, 10, 55, 50);
ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
ctx.fillRect (30, 30, 55, 50);
}
}
</script>
</head>
<body onload="draw();">
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
Expected results:
Up to firefox5 the page loaded correctly and set the canvas width to 95% of the page width.
Comment 1•13 years ago
|
||
Is this still happening with a current trunk build? I seem to recall a bug report on this in the last few months that was fixed....
Whiteboard: DUPEME
Reporter | ||
Comment 2•13 years ago
|
||
I don't know, I only tried the regular 6.0 version.
Comment 3•13 years ago
|
||
Right; I'm just asking whether you're willing to try a current beta or aurora version, say.
(In reply to alberto.maccioni from comment #0)
> document.getElementById('canvas').width=document.width*0.95;
document.width is no longer supported, see
https://developer.mozilla.org/en/Firefox_6_for_developers#DOM
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Whiteboard: DUPEME
Comment 5•13 years ago
|
||
Oh, right. document.width*0.95 == 0 in Firefox 6 and later, so you're setting the canvas width to 0.
Reporter | ||
Comment 7•13 years ago
|
||
Ok, problem solved, thanks.
You need to log in
before you can comment on or make changes to this bug.
Description
•