HTMLInputElement in IE7
- by Vladislav Qulin
I'm writing an extension for crossbrowser input&textarea selection getter and setter.
So that's the way i write my code:
HTMLInputElement.prototype.getSelectionRange = get_selection_range;
HTMLInputElement.prototype.setSelection = set_selection_range;
HTMLTextAreaElement.prototype.getSelectionRange = get_selection_range;
HTMLTextAreaElement.prototype.setSelection = set_selection_range;
get_selection_range and set_selection_range are those extended functions. So i just wanted to replace
someInputElement.selectionStart = a; // and whole lot of code due to browser
someInputElement.selectionEnd = b; // compatibility
with just
someInputElement.setSelection(a, b);
someInputElement.setSelection({ start: a, end: b });
someOtherElement.setSelection(someInputElement.getSelection());
But then i met couple of difficulties in IE7.
First of all, IE7 doesnt know what is HTMLInputElement.
I don't want to extend whole Object. Well, that would be the last thing i'll do, but i want to evade it.
Functions get_selection_range and set_selection_range are alright, don't ask what's within, you've seen it couple of times already.
So the question is: is there any legit substitution for HTMLInputElement in JS for IE7?