Html5 div over canvas crossbrowser

时间:2012-10-13 09:24:06

标签: javascript html5 canvas

我尝试在整页画布上放置一个div。在Chrome中工作很棒,但是在firefox和ie9中它会变成'kaput'。

以下是该代码的链接(在firefox chrome和ie9中尝试过)只有chrome似乎有用;

http://jsbin.com/ubolan/1/edit

1 个答案:

答案 0 :(得分:2)

在IE9文档中没有属性document.width/document.height,因此您将画布宽度/高度设置为0.

尝试使用

canvas.width = document.body.clientWidth;
canvas.height = document.body.clientHeight;

canvas.width = $(document).width();
canvas.height = $(document).height();
相关问题