Math Jazz — Mathias Bynens’s shizzle, y’all



Note: This site might seem inactive… That’s because it is. Don’t worry though, I’m still coding webpages and stuff! If you’re interested, I suggest you get a translator and head over to Qiwi; or you could just check the latest site we’ve been working on: Apotheek Goethals – Debrabandere. Enjoy!

Online HTML editor with real-time preview

Via del.icio.us I stumbled upon The Real-time HTML Editor™. This indeed is a cool little tool for experimenting with (X)HTML, though I found its code could be better. A couple of Bad Things it involves are frames, hard refreshes, and no semantics. Since live previews are commonly-used bits of JS in the world of weblogs, I figured this could be done better. And look: even I managed to create an online HTML editor with real-time preview and no hard refreshes! How cool is that? :)

Filed under JavaScript, XHTML · August 31st, 2005

Comments (10)

Listed below are the responses for this entry.

  1. Krijn Hoetmer:
    This commenter’s Gravatar

    Wow! :D That’s just too kewl! To be really honest; the first one sucks donkey arse. I read about it on digg, but I can’t really understand why 859 people would actually like it that much. I mean, it doesn’t even work in Opera! :] And everybody loves Opera!

    I like the sortable-colorized-row-table-thingy more ;)

    Comment posted on September 1st, 2005 @ 10:52 am
  2. Stacy:
    This commenter’s Gravatar

    To answer your question, it is VERY cool.

    Comment posted on September 6th, 2005 @ 4:21 am
  3. Jesse Ruderman:
    This commenter’s Gravatar

    A couple of Bad Things it involves are frames, hard refreshes, and no semantics.

    Frames give you isolation, which is nice if you’re testing scripts or layout CSS. Using innerHTML (like your version does) prevents scripts from running at all. Your version makes resizing impossible; frames give my version resizability for free.

    I’m not sure what you mean by “hard refreshes” and “no semantics”.

    You should use oninput instead of onkeydown. onkeydown doesn’t fire when you paste by right-clicking and selecting “Paste”, for example.

    Comment posted on September 10th, 2005 @ 12:35 pm
  4. Mathias:
    This commenter’s Gravatar

    Frames give you isolation, which is nice if you’re testing scripts or layout CSS. Using innerHTML (like your version does) prevents scripts from running at all. Your version makes resizing impossible; frames give my version resizability for free.

    Fair enough. I guess resizability could be added to my implementation through some spiffy liquid CSS design l33tage though. height: 50%;, anyone? Oh, and by the way, scripts can in fact be run — you just need to call them from inside onclick attributes, e.g. <a href="http://foo.bar/" onclick="alert('Seriously, you really intend to visit foo.bar?! Alright, go ahead…');">foo.bar</a>

    I know that might sound like a weak argument, but I just couldn’t resist mentioning it as you said […] prevents scripts from running at all (emphasis mine). Similarly, CSS can be added inline as well, e.g. <a href="http://foo.bar/" style="color: #fec; text-transform: uppercase; background: #000; padding: 4px 1px; text-decoration: none;">foo.bar</a>. Indeed not a very semantical way of inserting JS/CSS, but then again it’s just a tool for testing new stuff, right?

    I’m not sure what you mean by “hard refreshes” and “no semantics”.

    Your tool refreshes the bottom frame by every keystroke made. By the time you’ve entered <html>, that’s six refreshes! I suppose it’s better to reload an in-page div than to reload an entire page.
    As for the “no semantics” comment, I was referring to HTML such as <body class="expand close" onload="update(); document.f.ta.select();">. Indeed, the kind of code you’d enter into my crappy editor ;)

    You should use oninput instead of onkeydown. onkeydown doesn’t fire when you paste by right-clicking and selecting “Paste”, for example.

    I tried your suggestion, but oninput didn’t seem to trigger anything.

    Comment posted on September 11th, 2005 @ 8:06 pm
  5. Jesse Ruderman:
    This commenter’s Gravatar

    oninput works for me in Firefox 1.5 Beta 1. What browser are you using?

    Comment posted on September 12th, 2005 @ 3:32 am
  6. Mathias:
    This commenter’s Gravatar

    oninput works for me in Firefox 1.5 Beta 1. What browser are you using?

    Firefox 1.5 Beta 1. All I do is replace the line saying inputTextarea.onkeydown = hp_update; with inputTextarea.oninput = hp_update;, but it doesn’t quite seem to work. Perhaps I need to tweak something else in the code as well?

    Comment posted on September 12th, 2005 @ 7:55 pm
  7. Jesse Ruderman:
    This commenter’s Gravatar

    Try using addEventListener(). See Bug 195696: Setting textbox.oninput has no effect.

    Comment posted on September 14th, 2005 @ 8:38 am
  8. Chris Burkhardt:
    This commenter’s Gravatar

    Cool. I haven’t looked at the code for either, but I actually found Jesse’s more usable. Yours is always a character behind… and I like how the frame allows me to size each pane.

    But the not-so-semantic use of the H3 element in his example text is a bad example… Mathias’s is styled prettier :)

    They are both neat and inspiring.

    Comment posted on September 17th, 2005 @ 3:19 am
  9. asdf:
    This commenter’s Gravatar

    Your solution doesn’t seem to support the body tag and CSS, unlike the Squarefree version.

    Comment posted on July 7th, 2006 @ 9:27 am
  10. Eddy Young:
    This commenter’s Gravatar

    Have you tried this one?

    HTML Editor with Live Preview

    Made by me, of course, but well worth a try.

    Comment posted on January 18th, 2007 @ 10:38 pm