I have seen in many weblogs when we select text the background color of the text changes rather than usual blue. This Tech Works in Firefox and Safari, is there any method a
Not supported on IE as far as I know. Unless there's some clever hack I don't know about.
This?
<style>
::selection {color:red;background:yellow;}
::-moz-selection {color:red;background:yellow;}
</style>
http://www.w3schools.com/cssref/tryit.asp?filename=trycss3_selection
I think it would be difficult to emulate
I think you should use CSS for the browsers that support it, and wait patiently for IE to adopt this.
You could always remove it.
if (window.getSelection) {
if (window.getSelection().empty) { // Chrome
window.getSelection().empty();
} else if (window.getSelection().removeAllRanges) { // Firefox
window.getSelection().removeAllRanges();
}
} else if (document.selection) { // IE?
document.selection.empty();
}
It can't be done in IE with pure CSS and I don't know of any pre-packaged JS that will get the job done, either.