JavaScript內容選取事件(onselect)

內容選取事件(onselect)


#選取事件,當文字方塊或文字網域中的文字被選取時,觸發onselect事件,同時呼叫的程式就會被執行。

如下實例,當選擇文字後,彈出禁止賦值警告對話方塊

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script>
            function fun(){
                window.alert("这是个人简介,禁止复制")
            } 
        </script>
    </head>
    <body>
        <form>
            个性介绍:<br/><textarea name=" introduction" cols="30" rows="4" onselect="fun()">小明:
            PHP高级工程师
            全栈工程师</textarea>
        </form>
    </body>
</html>


#
繼續學習
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script> function fun(){ window.alert("这是个人简介,禁止复制") } </script> </head> <body> <form> 个性介绍:<br/><textarea name=" introduction" cols="30" rows="4" onselect="fun()">小明: PHP高级工程师 全栈工程师</textarea> </form> </body> </html>
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!