Storing Highlighted text in a variable
<p>Is there a javascript function that will allow me to capture the text that is currently highlighted with the cursor and store it in a variable? I've been trying document.selection.createRange().text but this hasn't been working. Are there any possible alternatives? Here's the code:</p>

<pre><code>function moremagic(){
var output = document.selection.createRange();
alert("I Work!");}
</code></pre>

<p>When I run the function, it doesn't make it to the write statement so I know something is wrong.</p>
