Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Thank you for bringing this up! Apparently, the JavaScript behind canvases gets disabled. I'll think something out.


sort by: page size:

What do I do if you want to use Canvas if JS is enabled but degrade gracefully if it isn't? Use vector graphics? Generate images on the server?...

(I'm specifically not interested in "everyone has JS enabled anyway" responses)

edit: I'm using Firefox 3.0.13 on Ubuntu Linux and the text doesn't render at all in canvas elements... what gives?


thanks for suggestion. but css is not usable when I handle canvas

Alternatively, just put some invisible DOM elements on top of the canvas and put your click handlers on those. It's imagemaps all over again ;)

How do you fix it without disabling canvas?

Ah yes I missed the var canvas line and just presumed the code was getting a context on the selected div instead, a feature I didn't know was possible (it isn't).

The canvas declaration is staring right at me now that I review it again. That's life...


What about accessibility? As far as I know canvases don't offer ways to expose the same semantic information about their contents as the DOM.

My bad. Seems that a number of browsers block saving canvas elements as a security precaution. For now, I can only recommend trying a different browser as a workaround.

Nice. If your canvas isn't interactive, render it on the server with the same codefor browsers that don't support canvas (i.e. I.E.)!

HTML Canvas element + javascript?

I've never done anything with canvas, but I've written jquery plugins. Let me know if I can help. And let us know if you post the source code.

The article mentions why they couldn't use canvas for this: they are running this code in a worker, and canvas support in workers is not great in browsers so far.

The problem with using the canvas functionality for everything is that it's an all-or-nothing proposition, and you end up having to write a lot of stuff that is already handled by the browser, or can only be handled by the browser (think bi-directional text/NLS issues).

Seems like it should be possible to do everything in the browser using canvas.

Canvas has accessibility issues for screen readers as well as for SEO purposes.

Using JavaScript to render to a canvas will work in all modern browsers, while maintaining (or even enhancing) the CSS's flexibility. I first thought the JavaScript solution would even be about the length of Moeed's CSS, but after writing it out my code's about 5x longer :(

edit: here's a jsfiddle of it in action http://jsfiddle.net/MftVp/


you're still in the SPA. You generally need some sort of painters algorithm to repaint the canvas anyway. When the canvas comes back you would just repaint it from JS memory.

Canvas in particular has issues web devs have to deal with beyond their "normal" duties. Accessibility is simply not even a thing in canvas. Google Docs had to implement an entire parallel invisible DOM structure to emulate what they draw on the canvas when they were switching over to the canvas. And, of course, that DOM structure has to be in sync with canvas.


Awesome! Thanks for that tip. It hadn't occurred to me that that was possible, but, yeah, that makes sense.

I might pick my Canvas experiments back up, then, as R and the other packages are outside the scope of my day-to-day work, but I could see a JS implementation being useful. Thanks again.


Hmm, just a gray screen here. I allowed Javascript and even permitted it to read canvas data. Does this only work on some specific browser?

To bad that it is not working with a background canvas. http://codepen.io/FWeinb/pen/0378ed8ad8a56f4f989ed8085baf5cd...
next

Legal | privacy