Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Copy-Paste from MS Excel fails with IE but works with Firefox


penders - 3:38 pm on Jan 26, 2012 (gmt 0)


There is a workaround... in the onpaste event you could intercept the pasting operation and in IE (since only IE supports the clipboardData object) remove the newlines and manually write it to the control, preventing the usual paste operation.

Just to add, regarding your regex, \s includes \n so don't need to include both and you probably want to replace sequences of white-space with a single comma rather than just one. As it stands at the moment two spaces would result in two commas. All you need is
/\s+\g - however, this could still result in an unwanted comma at the start or end of the string (it needs trimming first). However, I think you would be better to do this in PHP, since you're going to have to do it in PHP anyway.


Thread source:: http://www.webmasterworld.com/javascript/4410903.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com