Hi. I am trying to create a function in js that returns the html code for the selected text in the page. I've searched google and i found only simple text selection. here is the code of what i've found <HTML> <HEAD> <TITLE>Getting Selected Text</TITLE> <SCRIPT LANGUAGE="JavaScript"> var isNav4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4) var isNav4Min = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4) var isIE4Min = (navigator.appName.indexOf("Microsoft") != -1 && parseInt(navigator.appVersion) >= 4) function showSelection() { if (isNav4Min) { document.forms[0].selectedText.value = document.getSelection() } else if (isIE4Min) { if (document.selection) { document.forms[0].selectedText.value = document.selection.createRange().text event.cancelBubble = true } } } if (isNav4) { document.captureEvents(Event.MOUSEUP) } document.onmouseup = showSelection </SCRIPT> </HEAD> <BODY> <H1>Getting Selected Text</H1> <HR> <P>Select some text and see how JavaScript can capture the selection:</P> <H2>ARTICLE I</H2> <P> text text text text text text text text text text text text text </P> </HR> <FORM> <TEXTAREA NAME="selectedText" ROWS=3 COLS=40 WRAP="virtual"></TEXTAREA> </FORM> </BODY> </HTML> Code (markup): this example only returns the selected text not the html tags. I'm interested in a function that returns html code. Any help will be useful . Thanks you
no. innerHTML shows info from a tag. anyway i found the problem but I don't think it's possible. the browser wil add automatecly the missing tags in your selected text