The Artima Developer Community
Sponsored Link

Web Buzz Forum
Embedding images in HTML

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Stuart Langridge

Posts: 2006
Nickname: aquarius
Registered: Sep, 2003

Stuart Langridge is a web, JavaScript, and Python hacker, and sometimes all three at once.
Embedding images in HTML Posted: Oct 18, 2003 1:55 PM
Reply to this message Reply

This post originated from an RSS feed registered with Web Buzz by Stuart Langridge.
Original Post: Embedding images in HTML
Feed Title: as days pass by
Feed URL: http://feeds.feedburner.com/kryogenix
Feed Description: scratched tallies on the prison wall
Latest Web Buzz Posts
Latest Web Buzz Posts by Stuart Langridge
Latest Posts From as days pass by

Advertisement

There's a neat trick -- you might have seen it in Lee Semel's 5k Wolfenstein game for the 5k competition -- where you can embed images directly in a page, rather than have the image data in separate files. Semel demonstrated with XBM images, which are black-and-white image files that (if you look at the image data in the file) actually look like C code defining the image. (See Semel's notes above for more on this.)

So, thought I, that should work with non-XBM images too, right? I mean, if we can do src="javascript:makexbm()" and have our makexbm() function return C code for an array, there's no reason why it can't return binary data that makes up a GIF or PNG image, right? Right? Well, let's see:

Is there an image here? ()

All I've done there is made the src attribute of an img tag be a javascript string containing binary data. If you're using a Mozilla based browser, you should see a little red ball. If you're using IE...broken image. Damn. I'm not the first guy to discover this, either. Roger Critchlow wrote an essay about inline images on web pages, offering a few other ways that it might work (data: URLs, document.write, others). And, guess what: they all only work in Mozilla. IE, not a chance. So, it's not possible to embed images in a web page if that page is to be displayed in IE.

Ah! I hear you say. Can't we use MHTs for this? MHTs are web archives -- IE allows you to save a page as an MHT, and all the resources on that page (images, stylesheets, the works) get bundled up into one MHT file which IE can then open later. (It's actually an HTML email in format, but it works.) So, maybe they're a solution? Nope. Mozilla doesn't support MHT's. They're working on it, but it's not come up igh enough on the radar for it to get fixed, sadly, in the three years since the bug was filed. Some guys are actually prepared to offer money to get this bug fixed; they've got a couple of hundred dollars earmarked for the fix for this. But, until then, or until IE supports JavaScript embedded images (which will presumably happen never) there's no way of distributing a complex page in one runnable file, as far as I know. If anyone knows a way to get around this, ideally to convince IE to work with JavaScript URLs containing binary data, then I'd love to hear about it.

Read: Embedding images in HTML

Topic: HTML: More structural than semantic Previous Topic   Next Topic Topic: XML textarea validation bookmarklet

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use