In CSS, .someclass { text-transform: uppercase }
translates all text with class someclass
to uppercase, but when I select the text, copy, and paste into a text editor or e-mail, the letters retain their original case. But CSS doesn't support transformations other than letter case as defined in Unicode. Comments and answers to my previous question Display one letter as another in page while copying untransformed text recommended to suck it up and use JavaScript because it cannot be done with CSS alone. (This would require some conspicuous notification that scripts have not been applied, such as CSS that gets hidden when script runs.)
In JavaScript without Flash, how would I substitute characters in all text nodes, but have the clipboard and search not reflect the transformation? For example, I might want to change r
to w
, such that ruby wings
is displayed as wuby wings
, but selecting the text, copying it, and pasting it into Notepad produces ruby wings
, and Ctrl+F ruby
finds this.
I would store the original text somewhere, trap copy events, count characters in the selected text, and copy the same range from the original text. But that doesn't help with Ctrl+F. And answers to How to copy to the clipboard in JavaScript? recommend the use of Zero Clipboard, which relies on Adobe Flash Player, which is not installed on mobile or libre browsers. Besides, oncopy is nonstandard as of this writing. Or must I also suck it up and use Flash and then have copy and find misbehave without Flash?