• Лови промокод з яким знижка 50 грн - promo50grn

Сделать hover унифицированный вариант

Статус: Offline
Реєстрація: 18.06.2008
Повідом.: 21989
Сделать hover унифицированный вариант

собственно сабж, есть три скрипта, результат у всех разный с разными бро, может есть унифицированный ? три скрипта привожу:
===============================================
function dispatchMoveEvent(element, positionX, positionY) {
var moveEvent;

if("ontouchmove" in document) {
console.log('Creating a touchmove event for a touch-enabled browser.');
moveEvent = document.createEvent('Event');
moveEvent.initEvent('touchmove',true,true);

moveEvent.touches = moveEvent.targetTouches = [{
clientX: positionX,
clientY: positionY,
identifier: 0
}];

moveEvent.changedTouches = [{
clientX: positionX,
clientY: positionY,
identifier: 0
}];

} else if(window.MSPointerEvent) {
console.log('Creating an MSPointerMove event for IE.');
moveEvent = document.createEvent('MSPointerEvent');
moveEvent.initPointerEvent('MSPointerMove', true, true,window,0,positionX,positionY,positionX,positionY,false,false,false,false,0,null,0,0,0,0,0,0,0,0,0,0,0,true);
} else {
console.log('Creating a mousemove event.');
moveEvent = document.createEvent('MouseEvents');
moveEvent.initMouseEvent('mousemove',true,true,window,0,positionX,positionY,positionX,positionY,false,false,false,false,0,null);
}

console.log('Dispatching the event.');
var result = element.dispatchEvent(moveEvent);

if(result) {
console.log('The event was successfully dispatched');
} else {
console.log('The application prevented the event from being dispatched.');
}
};


==========================================

function extend(destination, source) { var eventMatchers = { 'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/, 'MouseEvents': /^(?:click|dblclick|mouse(?:down|up|over|move|out))$/ }; var defaultOptions = { pointerX: 0, pointerY: 0, button: 0, ctrlKey: false, altKey: false, shiftKey: false, metaKey: false, bubbles: true, cancelable: true }; for (var property in source) destination[property] = source[property]; return destination; } function simulate(element, eventName) { var eventMatchers = { 'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/, 'MouseEvents': /^(?:click|dblclick|mouse(?:down|up|over|move|out))$/ }; var defaultOptions = { pointerX: 0, pointerY: 0, button: 0, ctrlKey: false, altKey: false, shiftKey: false, metaKey: false, bubbles: true, cancelable: true }; var options = extend(defaultOptions, arguments[2] || {}); var oEvent, eventType = null; for (var name in eventMatchers) { if (eventMatchers[name].test(eventName)) { eventType = name; break; } } if (!eventType) throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported'); if (document.createEvent) { oEvent = document.createEvent(eventType); if (eventType == 'HTMLEvents') { oEvent.initEvent(eventName, options.bubbles, options.cancelable); } else { oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView, options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element); } element.dispatchEvent(oEvent); } else { options.clientX = options.pointerX; options.clientY = options.pointerY; var evt = document.createEventObject(); oEvent = extend(evt, options); element.fireEvent('on' + eventName, oEvent); } return element; } simulate(document.evaluate("(//*[contains(@Class, \'nolink\')])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue, "mouseover");


==========================================
if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('mouseover', true, false); document.getElementsByClassName('external-processed')[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('onmouseover');}
 
Назад
Зверху Знизу