I was using simple textarea element and then replaced it with iframe with designMode=’on’ to give user the possibility to mark some text and make it italic. But I still want an iframe to look like textarea, so I need a border around it similar to that which appears in Chrome and Safari when textarea is active. How can I achieve such an effect?
I was using simple textarea element and then replaced it with iframe with designMode=’on’
Share
I solved my problem in a following way.
When I need to highlight iframe for the first time I’m creating textarea with negative ‘left’ coordinate (so that it’s invisible to user), give it a focus and get its CSS properties via window.getComputedStyle. Then I’m applying four of these properties to focused iframe: ‘outline-color’, ‘outline-style’, ‘outline-width’ and ‘outline-offset’.
For some reason Safari 5 wouldn’t give you correct value for ‘outline-offset’. So for the time being I hardcoded it to be ‘-2px’.