Would it be possible to create a virtual web browser, inside your existing web browser, using canvas, to achieve near pixel perfect representation of websites across all browsers?
3 Answers
Take a look at http://html2canvas.hertzen.com/ - It's a HTML renderer using a Canvas element. There are a few limitations (some CSS3 properties don't work) and you can only do static images with it. But it's still very cool.
Also it's still going to be browser-specific in terms of exact positioning of elements.
2 Comments
user1277170
Making a new canvas, 300x300, then adding a red square, (50,50)(100,100) will surely display exactly the same on all browsers that implement the canvas?
PhonicUK
Mostly, Yes. But the project I posted above depends (as far as I know) depends on the browsers HTML parsing to understand the document that it is to render. Also while something as simple as a red square would certainly render the same across browsers, other more complex images involving paths and blending would not be guaranteed to be the same pixel-for-pixel across browsers.
Theoretically: Yea, maybe... no.
Practically: Hell no.
You can't play flash / silverlight / java applets on canvas. Also, you'd have to:
- Manually parse the DOM,
- Apply CSS,
- Execute JS,
- Render everything,
- Make input elements,
- dropdown menu's,
- hyperlinks,
- mouseovers,
- and all that kind of interaction work,
- And whatever else I've forgotten.
- Like proper Anti-Aliasing
3 Comments
user1277170
Seriously, you're using flash/silverlight/java app as an argument against canvas? Canvas was made to remove the need of them. You could use the browser to process most of it, you would just need to render it. Inputs and all aren't that hard surprisingly.
PhonicUK
@user1277170 that's not what he was saying. He was saying that if you tried to use a canvas to render the page, any flash/SL on the page couldn't be rendered.
Cerbrus
@user1277170: Canvas was made to replace them, yes. But it's not nearly there yet. I was just listing things that can't be done in canvas.
Only with tremendous difficulty.
Why not just use <iframe>?
1 Comment
user1277170
iframe uses the same rendering as the browser. You must have missed the "to achieve near pixel perfect representation of websites across all browsers" bit.