最近在寫云筆記,學到了兩個有用的API
oncontextmenu 事件,在用戶右擊鼠標觸發(fā)并打開上下文菜單,可以用其中自定義事件,并用 return false 攔截瀏覽器默認事件。
el.oncontextmenu=()=>{
// some code...
return false;
}
onselectstart 事件,用戶選中文字(藍框,可復制),同樣可用 return false 攔截。
el.onselectstart=()=>{
return false;
}