In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Javascript how to hide the right button, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Javascript hide the right button method: 1, open the corresponding code file; 2, use the "_ window.oncontextmenu=function (e) {e.preventDefault ();}" method to disable the right mouse button menu.
This article operating environment: Windows7 system, javascript1.8.5, Dell G3 computer.
How does javascript hide the right button?
Js sets or disables the right mouse button menu
The oncontextmenu event is triggered when the user clicks the right mouse button
Js disables the right mouse button menu
_ window.oncontextmenu=function (e) {/ / it is important to cancel the default browser with its own right button! E.preventDefault ();}
Js customize the right mouse button menu
Html prepare Custom menu item function 1 function 2 function 3 function 4 function 5css set menu item style # menu {width: 0; / * set to 0 hide Custom menu * / height: 125px; overflow: hidden; / * hide overflow element * / box-shadow: 0 1px 1px # 888 1px 1px 0 1px # ccc; position: absolute / * Custom menus are positioned relative to body elements * /} .menu {width: 130px; height: 25px; line-height: 25px; padding: 010px;} js controls the display and hiding of menus _ window.oncontextmenu=function (e) {/ / it is important to cancel the default browser with a right button! E.preventDefault (); / / get our custom right-click menu var menu=document.querySelector ("# menu"); / / locate menu.style.left=e.clientX+'px'; menu.style.top=e.clientY+'px'; / / change the width of the custom menu to show menu.style.width='100px'; menu.style.height='auto' according to the location of the mouse click in the event object } / / Click anywhere with the left mouse button to close the right-click menu _ window.onclick=function (e) {/ / the user triggers the click event to close it, because it is bound on the window and bubbles by the event, which will not affect the menu function document.querySelector ('# menu'). Style.height=0;} after reading the above, have you mastered how to hide the right button in javascript? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.