The mobile PC listens to the user copy content, and the pc listens to the user copy

Source: Internet
Author: User

The mobile PC listens to the user copy content, and the pc listens to the user copy

Recently, in response to project requirements, in order to obtain information that more users want to search for, you need to obtain the content copied by users and then transmit it to the background to better understand customer needs, I have planted a big heel in this method. I only want to consider one of them, but I don't know how to use them. I am stuck in my head and write down it as soon as possible. I hope I can grow and improve slowly.

<Div class = "contenttext" oncopy = "myFunction ()"> used to test the mobile phone copy content.
Flexible use to avoid head freezing flexible use to avoid head freezing
Used to test the monitoring mobile phone copy content.
Flexible use to avoid head freezing flexible use to avoid head freezing
Used to test the monitoring mobile phone copy content.
Flexible application to avoid head freezing flexible use to avoid head freezing to test monitoring mobile phone copy content
Flexible use to avoid head freezing flexible use to avoid head freezing

</Div>
 
<Script> function myFunction () {var txt; txt = window. getSelection (); if (txt. toString (). length> 1) {alert ("Copied:" + txt); $. ajax ({// transfer data to the background}) }}</script>
 

 

 

 

The window. getSelection () is to obtain the selected content, detailed description see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getSelection

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.