javascript - Prevent selection being greyed out in iframe in Firefox without using contenteditable -



javascript - Prevent selection being greyed out in iframe in Firefox without using contenteditable -

in firefox 3 , later (and older versions), selecting content within iframe seems utilize gray selection background colour used document doesn't have focus, if iframe have focus. exception have been able find when content within iframe editable. not case in other browsers. here's illustration illustrating this:

http://jsfiddle.net/97vjz/

this unfortunately prevents styling selection within iframe using ::-moz-selection css pseudo-element because applies non-grey selections:

http://jsfiddle.net/yyxsy/1/

my question is: possible prevent iframe's selection beingness gray in firefox without using contenteditable / designmode?

update

this seems happen on dynamically written iframes: using separate file , src attribute solves problem. however, need work dynamically written iframes.

i tried reproduce problem "real" page iframe content , works want: bluish colored selection! (ff 5.0)

see: http://jsfiddle.net/97vjz/8/

it seems generated content has problem, create page (php/asp(x)) generates content circumvent problem.

another solution utilize javascript generated content load src="javascript:'<html />'" (actually tim's own solution comments below.)

a simple illustration script: http://jsfiddle.net/97vjz/9/

iframe.src='javascript:\'<html><body>' + content + '</body></html>\'';

javascript css firefox iframe selection

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -