Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nesting Lists using execCommand('insertunorderedlist')?

Status
Not open for further replies.

crazyboybert

Programmer
Joined
Jun 27, 2001
Messages
798
Location
GB
Hi

I have an HTML editor written for IE using the execCommand method and associated functionality. M$oft seem to think that it is possible to nest lists (or any elements for that matter) as far as you like though I ma having problems with this.

To insert an unordered list for example the following code is used..

Code:
document.execCommand('insertunorderedlist');

this works fine and turns selected text into a list element or creates an empty list if no text is selected. If the same code is ran again whilst the cursor is on a list item the selected item is switched back to plain text when what i would like is for the a new nested list to be created and for backspace to be used to end a list...

i have tried adding an id to created elements using

Code:
document.execCommand('insertunorderedlist', false, sID);

but this seemingly doesnt work at all though its documented as right and throws no errors. I figured if each list had its own unique ID then maybe it would list them instead of operating on the selected list but no such joy..

Anybody got this to work or experienced similar probloems and foudn a workaround?

Cheers up front for any help at all

Rob

------------------------------------

Go placidly amidst the noise and haste,
find what peace there may be in silence.
-Anon

------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top