oncopy和onpaste

來源:互聯網
上載者:User

標籤:java   使用   資料   art   ar   div   javascript   c   

       在Javascript中,有對應的事件能夠監聽複製和粘貼,那就是oncopy和onpaste。

       oncopy:

  • demo:
    • <body oncopy="alert(‘不能複製‘);return false;">你能複製我嗎?</body>


  • 使用情境:
    • 非常多網站上的頁面內容是不同意複製的,這樣能夠防止使用者或者程式惡意的去抓取頁面資料。曾經的起點閱讀小說時,就是不同意複製內容,如今更狠,把左鍵選擇內容和右鍵菜單也都屏蔽了。
        onpaste:

  • demo
    • <input type="text" nane="cardNum" onpaste="return false;" />


  • 使用情境:
    • 網銀轉賬時,輸入對方卡號,須要輸入兩次,通常第二次輸入的輸入框是不同意粘貼的,這樣就在一定程度上保證了卡號的準確性。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.