Highlight some text on this webpage, then click anywhere on the document basically. Your selection will disappear.
Is there a way to stop this behavior when a user clicks on a specific element, either by CSS or Javascript?
Example:
var element = document.getElementById ("foo"); Foo.onclick = function (e) {// some magic is here that prevents discount from}}
or
foo.style. PreventDyslect = "true"; Edit: Maybe I can save the selection, then after the "MouseClick" can I restore the selection? There is a way of store aselection, and then search ? Thank you!
"Foremost falls" as well as "E.Provident Default" (FMF) and onMoside work in Safari Does not IE, the only solution for IE, as far as I can tell, is to throw an error.
It works in all browsers (but causes an error in IE, because prevention is not a method):
// on the 'Test' element Clicking will not deselect the text Var test = document.getElementById ("test"); Test.onmousedown = function (e) {E = E || Window.event; E.preventDefault (); }
I still want to do this error-free IE, if possible.
Thank you for Paolo Bergantino for the "Omnoduct" tip.
Comments
Post a Comment