»
EnglishFrenchVietnamese

Print - Disable Text Selection - JavaScriptBank.com

Full version: jsB@nk » Security » Disable Text Selection
URL: http://www.javascriptbank.com/disable-text-selection.html

Disable Text Selection © JavaScriptBank.comUse this script to disable the selection of text on a page. It's very simple using two of the built-in JavaScript events to cancel the selection before it starts. You can even attach the events to a specific element.

Full version: jsB@nk » Security » Disable Text Selection
URL: http://www.javascriptbank.com/disable-text-selection.html



JavaScript
<script language="javascript">// Created by: James Nisbet (morBandit) :: http://www.bandit.co.nz/window.onload = function() {  document.onselectstart = function() {return false;} // ie  document.onmousedown = function() {return false;} // mozilla}/* You can attach the events to any element. In the following exampleI'll disable selecting text in an element with the id 'content'. */window.onload = function() {  var element = document.getElementById('content');  element.onselectstart = function () { return false; } // ie  element.onmousedown = function () { return false; } // mozilla}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<p id=content><b>You can not select text in this section because of this script</b></p><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->