-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmouseover.js
44 lines (40 loc) · 1.24 KB
/
mouseover.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Note: A element does not listen to mouseover event. Please make sure the what event listen to with Developer Tools.
* https://developers.google.com/web/updates/2015/05/easily-jump-to-event-listeners
*
* 注意:要素によってはmouseoverイベントが登録されていないものがあります。どのイベントが登録されているかDeveloper Toolsでの確認をしてください。
* https://developers.google.com/web/updates/2015/05/easily-jump-to-event-listeners
*/
/**
* Locate the element
* 要素を探す
*/
var selector = "<TODO: REPLACE SELECTOR>";
var element = document.querySelector(selector);
/**
* Stop process if it does not exist
* 要素がなければ処理を中断する
*/
if (!element) {
throw new Error('Error: cannot find the element with selector(' + selector + ').');
}
var event;
if (typeof(Event) === 'function') {
/**
* For modern browser
* モダンブラウザの場合
*/
event = new Event('mouseover');
} else {
/**
* For IE 11
* IE 11 の場合
*/
event = document.createEvent('Event');
event.initEvent('mouseover', true, true);
}
/**
* Fire a mouse over event
* マウスオーバーイベントを発火させる
*/
element.dispatchEvent(event);