Insert html at cursor in a contenteditable div

I have a div with contenteditable set and I am capturing keypress using jquery to call preventDefault() when the enter key is pressed. Similar to this question which inserts text at the cursor, I would like to directly insert html, for brevity we'll say its a br tag. Using the answer to the question above actually works in IE as it uses the range.pasteHTML method, but in other browsers the br tag would appear as plain text and not html. How could I modify the answer to insert html and not text ?

test if window has focus

How do you test if the browser has focus?

Is JavaScript multithreaded?

Here's my issue - I need to dynamically download several scripts using jQuery.getScript() and execute certain JavaScript code after all the scripts were loaded, so my plan was to do something like this:

jquery - difference between $.functionName and $.fn.FunctionName

In jQuery, I have seen both the following ways of defining a jQuery function:

how do i base64 encode and decode using javascript?

just wondering if there are any methods in JavaScript that i can use to encode and decode a string using base64 encoding?

What does “options = options || {}” mean in Javascript?

I came over a snippet of code the other day that I got curious about, but I'm not really sure what it actually does;

How can I delete all cookies with Javascript?

I have written code to save the cookies in Javascript. Now I need to clear the cookie irrespective of values that I assigned.

Creating a new DOM element from an HTML string using built-in DOM methods or prototype

I'm trying to create an element dynamically using an HTML string. Here's a simple example using both prototype and DOM:

Facebook “Like” button callback

I am interested in implementing the facebook "Like" button, but I would like to know what user is clicking on this button so I can get some useful information from this. From what I have read, facebook is leaving us in the dark on who is clicking on what. ANyone have an idea on how I could track which user clicked on a like button for a particular product?

JavaScript property access: dot notation vs. brackets?

Other than the obvious fact that the first form could use a variable and not just a string literal, is there any reason to use one over the other, and if so under which cases?

How do i align this text correctly?

I wrote this polar clock today and i am almost finished exept i want to align my text inside the line similar to this. Does anyone know how to do this? Ive tried to use FontRenderContext and font metrics but i cant seem to get it to work. Here is the whole source code so you can compile it and see for yourselves.

Embed a web browser within a java application [closed]

Possible Duplicate: Is there a way to embed a browser in Java?