View Full Version : Javascript within an editable iframe


banaax
09-20-2006, 11:35 AM
I'm trying to make an advanced text editor on the web, I think my best option is an iframe (a text area like this forum uses isn't sufficient since you can't decorate text within the textarea). I'm working with something very simililar to the editor on http://devedge-temp.mozilla.org/viewsource/2003/midas/01/index_en.html.

My problem (also a problem on site above), when you type something in IE and click outside of what you typed (like the middle of the iframe), the cursor goes to the end of the text, exactly what I want, this doesn't happen in mozilla, you have to click next to the text to get the cursor to move to the end of the text. One solution I was thinking about is adding an onclick event to the area of the iframe that moves the cursor to the end of the text, but since the iframe is not an html element (something like that) you can't add javascript functions, and since the iframe is in designMode any javascript I add in the iframe source doesn't work that (does when designMode is off). Any help is apprechiated.

banaax
09-20-2006, 09:40 PM
Okay I figured out my click problem, the solution was to add a textarea inside the iframe with height and width of 100%, I still need to use javascript within the iframe though. One thing I want to to do is syncronize the iframe scroll with a div outside of the iframe.

banaax
09-22-2006, 03:58 PM
nevermind solved that problem too

Paz
09-22-2006, 11:05 PM
LOL... sorry banaax, I gave up on all but the most basic javascript a long time ago!

Glad you sorted it out!

BSolveIT
09-24-2006, 03:40 PM
banaax - sorry, I have to ask as it seems like you want to reinvent the wheel. Are you just trying to create some kind of inline editor? If so, why don't you just use one of the many that are around that you could download? Some are better than others, to be sure, so I guess it depends on your needs. Ultimately, what are you trying to achieve?