找回密码
 注册

QQ登录

只需一步,快速开始

查看: 379|回复: 0

Disable selection operation on a webpage

[复制链接]
发表于 2012-3-21 10:12:34 | 显示全部楼层 |阅读模式
本帖最后由 Test 于 2012-3-21 10:15 编辑

Add these javescript code in HEAD module:
  1. <script type="text/javascript">

  2. function disableSelection(target){
  3. if (typeof target.onselectstart!="undefined") //For IE
  4.         target.onselectstart=function(){return false}
  5. else if (typeof target.style.MozUserSelect!="undefined") //For Firefox
  6.         target.style.MozUserSelect="none"
  7. else //All other route (For Opera)
  8.         target.onmousedown=function(){return false}
  9. target.style.cursor = "default"
  10. }
  11. </script>
复制代码

Then, in the body, usually at the final part of it, add:
  1. <script type="text/javascript">
  2. disableSelection(document.body)
  3. </script>
复制代码

and ...

Done.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )

GMT-8, 2026-6-16 14:27 , Processed in 0.013798 second(s), 16 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表