Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to disable copying by javascript

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to prohibit copying in javascript". In daily operation, I believe many people have doubts about how to prohibit copying in javascript. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to prohibit copying in javascript". Next, please follow the editor to study!

In JavaScript, you can disable copying with the oncopy event, which is triggered when the user copies the content on the element, when you press "CTRL+C" or when you select copy in the browser's edit menu, and the syntax is "object.oncopy=function () {...}".

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

How to disable copying by javascript

The oncopy event is triggered when the user copies the content on the element.

Tip: the oncopy event is also triggered when the user copies the element, for example, copy

element.

Tip: the oncopy event is usually used for elements of type= "text".

Tip: there are three ways to copy elements and content:

Press CTRL + C

Select "Copy" from the Edit menu in your browser

Right-click the mouse button and select the Copy command from the context menu.

Grammar

In HTML:

Function myFunction () {document.getElementById ("demo") [xss_clean] = "you copied the text!"}

Output result:

At this point, the study of "how to prohibit copying of javascript" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report