2009年12月29日火曜日

ブラウザ機能抑止

ブラウザ機能抑止の世界では、

  • 右クリック

  • 戻るボタン

  • F5



あたりが抑止される対象だと思う。
まあ、ブラウザの機能を抑止するWebページってどうなんだ、
という議論は置いておいて。
(業務システムだとか、そういう場合かな)

またもや、jqueryを用いて抑止してみた。

一応、以下の場所ではBackspaceを許可。

  • <input type="text">

  • <input type="password">

  • <textarea></textarea>





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html lang="ja">
<head>
<title> .:: Sample Play Keepaway ::. Prohibit-01</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="cache-control" content="no-cache">
<meta name="Author" content="Sample">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<link rel="stylesheet" href="css/blue/style.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" href="css/default.css" type="text/css" />

  1. <script language="Javascript" type="text/javascript" charset="UTF-8" src="js/lib/jquery-1.3.2.min.js"></script>  
  2. <script type="text/javascript">  
  3. $(document).ready(function() {  
  4. // 戻るの禁止  
  5.     $(document).keydown(function(event){  
  6.         if (event.altKey && event.keyCode == 37) {  
  7.             return false;  
  8.         } else if (event.keyCode == 8) {  
  9.             if (event.srcElement.type != undefined &&   
  10.                 (event.srcElement.type == 'text' ||  
  11.                     event.srcElement.type == 'password' ||  
  12.                     event.srcElement.type == 'textarea')) {  
  13.                 return true;  
  14.             } else {  
  15.                 return false;  
  16.             }  
  17.         } else {  
  18.             return true;  
  19.         }  
  20.     });      
  21.     // 右クリックの禁止  
  22.     $(document).bind("contextmenu",function(e){  
  23.         return false;  
  24.     });  
  25.       
  26. });   
  27. </script>  


</head>
<body>
<h2>最初のページ</h2>
<div>
テキストボックス:<input type="text" name="sampleText" id="sampleText" size="20" value="さんぷるてきすと">
<br>
パスワードボックス:<input type="password" name="samplePassword" id="samplePassword" size="10" value="">
<br>
テキストエリア:<textarea name="sampleArea" id="sampleArea" rows="10" cols="20">ああああああああああああああああああああああああ
いいいいいいいいいいいいいいいいいいいい
</textarea>

<a href="./sample2.html">次のページへ</a>
</div>

</div>

</body>
</html>