JavaScript內(nèi)容選取事件(onselect)
內(nèi)容選取事件(onselect)
#選取事件,當(dāng)文字方塊或文字網(wǎng)域中的文字被選取時(shí),觸發(fā)onselect事件,同時(shí)呼叫的程式就會(huì)被執(zhí)行。
如下實(shí)例,當(dāng)選擇文字後,彈出禁止賦值警告對(duì)話方塊
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script> function fun(){ window.alert("這是個(gè)人簡(jiǎn)介,禁止復(fù)制") } </script> </head> <body> <form> 個(gè)性介紹:<br/><textarea name=" introduction" cols="30" rows="4" onselect="fun()">小明: PHP高級(jí)工程師 全棧工程師</textarea> </form> </body> </html>