Quote:
Originally Posted by balabaster
I've got something that kind-of works in IE. It's a little buggy, but I haven't had time to work out the bugs yet. If you've got something that works in IE, I'd be happy to see it.
well i threw the firefox code together off the top of my head.
turns out i guess i don't have an ie version of this.
i have code that happily wraps (fore example) "<b>xxx</b>" around selected text in a textarea, but if there is no selection at all, it doesn't work.
one crappy workaround i thought up would be to use execCommand("paste") to insert the clipboard into the text. haven't tested this on textareas though.
you could use another function to gain raw access to the clipboard from javascript:
function CB() //sets or read clipboard in IE accepts 1 arg to set, returns cb when empty { if (arguments.length) {window.clipboardData.setData('Text', arguments[0])} else { return window.clipboardData.getData('Text')} }//end CB
using it, you could then
1. backup the current clipboard text to a var
2. set the clipboard to the string to be inserted.
3. execCommand("paste")
4. set the clipboard to the var from step 1.
this could ruin the user's clipboard if he has for instance, and image or file on the clipboard, but would be ok if he had just plain text.