function select()
{
if (window.getSelection) { return window.getSelection().getRangeAt(0); }
else if (window.document.selection) { return window.document.selection.createRange(); }
return false;
}
var obj, w = window;
if (window.attachEvent) { obj = function (element, event, handler) { element.attachEvent('on' + event, handler); } }
else
{
obj = function (element, event, handler) { element.addEventListener(event, handler, false); };
}
function res ()
{
if(rang = select())
{
// не добавляется обработчик события
obj(rang.startContainer, 'keydown', function(e) { alert(23423) } );
}
}
obj(w, 'mousedown', res);