Question: I am using the following code for Highlighting the text in the Iframe but i cant get it to work 

```
  function getSelectedText() {
        if (window.getSelection) {;
            return window.getSelection().toString();
        } else if (document.getSelection) {;
            return document.getSelection();
        } else if (document.selection) {;

            return document.selection.createRange().text;
        }
    }
    $(document).ready(function () {

        $("#iframe1").live("mouseup", function () {
            selection = getSelectedText();
            if (selection.length >= 3) {

                $(this).html($(this).html().replace(selection, "<span class='highlight'>" + selection + "</span>"));

            }
        });
    });
    });

```

Answer: 
If `iframe1` is the ID of the `<iframe>`, you need to place it in quotation marks for your selector.

So instead of:

```
$(#iframe1).live("mouseup", function () {
   //...

```

you need:

```
$('#iframe1').live("mouseup", function () {
   //...

```
```
$( function() {
   var myiframe = $($.browser.msie ? frames["iframe1"] : "#iframe1");
   // doesn't work in Opera < 9
   myiframe.load( function() {
       selection = getSelectedText();

       //below code works but i dont know about $(this) will work or not but you can try your code
       //var w = this.contentWindow;
       //if(!w) w = myiframe[0]; // IE
       //alert("Number of anchors: " + w.$("a").size());
       //alert("Document title: " + w.document.title);

        if (selection.length >= 3) {
            $(this).html($(this).html().replace(selection, "<span class='highlight'>" + selection + "</span>"));
        }
   })
})

```