CarlKabbe
12-22-2006, 08:30 PM
I am allowing my customers to use a rich text editor (wysiwyg) on a jsp page to create snippets of HTML code that can be used to describe their items. When they want to add an image, table or custom tag (something we wrote), they are presented with a properties box created using javascript on the same page just below the editor. Upon clicking 'Insert' button on the properties box, I use javascript to create an HTML string with the tag information and insert the string into the edited page where the cursor was. The problem is that I can't seem to find a reliable way to know where the cursor was.
More information:
I am a C programmer who morphed to a Java programmer who knows some javascript.
The JSP page looks like this:
--------------------------------------------------------------------
Some text and text fields for some basic information
--------------------------------------------------------------------
The javascript wysiwyg editor
--------------------------------------------------------------------
The properties box (changes depending on the type of item being inserted)
--------------------------------------------------------------------
Submit button, etc. for the page (so the information can be persisted)
I have tried:
1. Seven days of searching the web for helpful hints.
2. Using a popup window to get the properties (doesn't work because in IE7, closing the popup also kills the session... I need to use some of the beans on the main window on the popup.)
3. Processing onMouseDown and onKeyDown events storing the element information in a global variable so I could use it later to know the point of insertion. (Has not been reliable and the arrow keys present real problems with where the cursor ends up as that is different from where it was pressed.)
I am frustrated because I don't seem to be gaining on the problem. I suspect it is because I have missed something very simple.
Does anyone have any ideas?
Thanks in advance.
Carl
More information:
I am a C programmer who morphed to a Java programmer who knows some javascript.
The JSP page looks like this:
--------------------------------------------------------------------
Some text and text fields for some basic information
--------------------------------------------------------------------
The javascript wysiwyg editor
--------------------------------------------------------------------
The properties box (changes depending on the type of item being inserted)
--------------------------------------------------------------------
Submit button, etc. for the page (so the information can be persisted)
I have tried:
1. Seven days of searching the web for helpful hints.
2. Using a popup window to get the properties (doesn't work because in IE7, closing the popup also kills the session... I need to use some of the beans on the main window on the popup.)
3. Processing onMouseDown and onKeyDown events storing the element information in a global variable so I could use it later to know the point of insertion. (Has not been reliable and the arrow keys present real problems with where the cursor ends up as that is different from where it was pressed.)
I am frustrated because I don't seem to be gaining on the problem. I suspect it is because I have missed something very simple.
Does anyone have any ideas?
Thanks in advance.
Carl