views:

269

answers:

3

I create iframe with designMode=on.

When I open web site in IE and move mouse cursor on iframe, the mouse cursor get changes into text-cursor (big letter I).

But when I open web site in Firefox, the corsur doesn't change and stays arrow-point cursor.

How to fix that?

 <script language="javascript" type="text/javascript">
        designer('content');

        function designer(editor) {
            var browser = navigator.userAgent.toLowerCase();
            isIE = (browser.indexOf("msie") != -1);

            document.writeln('<iframe id="' + editor + '"  width="600px" height="600px"></iframe>');


            var edit = document.getElementById(editor).contentWindow.document;                                
            edit.designMode = "On";

            if (!isIE) {
                document.getElementById(content).contentDocument.designMode = "on";
            }
        }

    </script>
+1  A: 

Maybe this page will help?

Rakesh Pai
not really... .
samuel
Why not? It should tell you everything you need.
Pekka
A: 
Try CSS, that should switch the cursor for you. 

iframe{cursor:crosshair} //all iframes on page
or
#content{cursor:crosshair} //just the element with the id "content"

Question? where is the variable content set in the call: document.getElementById(content).contentDocument.designMode = "on";

Do you mean editor as in: var edit = document.getElementById(editor).contentWindow.document;

Okay, I see your problem, link to http://devedge-temp.mozilla.org/viewsource/2003/midas/01/example2-index.html has the same issue and that's the Mozilla way.

Gareth
HAve you tried this yourself? Doesn't work
samuel
A: 

Your line:

if (!isIE) {
  document.getElementById(content).contentDocument.designMode = "on";
}

Should almost certainly read:

if (!isIE) {
  document.getElementById(editor).contentWindow.document = "on";
}

As it stands you're asking non-IE browser to find an element with id null, rather than an element with id 'content'.

However, that won't get you a text caret in your IFrame, even if it does make it editable.

The best I could come up with was:

  document.getElementById(editor).contentWindow.document.style.cursor = "text";

Which turns the cursor into a caret on the first line of the iFrame (i.e. at the top), presumably because that's the only editable bit at that point.

Zhaph - Ben Duguid
yes, only the first line.I need it to work for all lines...
samuel
Then you'd need to either supply more in the IFrame to fill it out, or settle for the fact that this is not how Firefox works.
Zhaph - Ben Duguid