日期:2014-05-16 浏览次数:20427 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style> body{ margin:0; padding:0; font-size:12px; background:#fff} .main{ width:960px; margin:auto; overflow:hidden; background:#D9D9D9} </style> <script src="js/jquery-1.6.4.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ text(); }); function text(){ var $text = $("#text"); $text.mouseover(function(){ $("body").attr({"onselectstart":"return true;","oncontextmenu":"return true;"}) }).mouseout(function(){ $("body").attr({"onselectstart":"return false;","oncontextmenu":"return false;"}) }) } </script> </head> <body onselectstart="return false;" oncontextmenu="return false;"> <div class="main"> <textarea id="text" name="" cols="" rows="" style="width:300px; height:200px"></textarea> </div> </body> </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <title></title> <style> body{ margin:0; padding:0; font-size:12px; background:#fff} .main{ width:960px; margin:auto; overflow:hidden; background:#D9D9D9} </style> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ text(); }); function text(){ var $text = $("#text"); $text.mouseover(function(){ document.oncontextmenu = null; }).mouseout(function(){ document.oncontextmenu = function (event){ var event = event || window.event; return false; }; }) } document.oncontextmenu = function (event){ var event = event || window.event; return false; }; </script> </head> <body> <div class="main"> <textarea id="text" name="" cols="" rows="" style="width:300px; height:200px"></textarea> </div> </body> </html>
------解决方案--------------------
http://www.codingforums.com/showthread.php?t=150345