teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

testで使っているphpファイルの追加と無駄な言葉を消しました

2019/01/19 07:26

投稿

wechsler
wechsler

スコア10

title CHANGED
File without changes
body CHANGED
@@ -5,8 +5,6 @@
5
5
 
6
6
  なので右クリックを例外にしたwindows.onblurを使いたいです。
7
7
 
8
- (めちゃめちゃ初心者なので伝え方も拙くてすみません)
9
-
10
8
  ### 発生している問題・エラーメッセージ
11
9
 
12
10
  ```
@@ -14,7 +12,7 @@
14
12
 
15
13
  ```
16
14
 
17
- ### 該当のソースコード
15
+ ### 改善したい部分のソースコード
18
16
  右クリックに反応してしまいます。
19
17
  ```javascript
20
18
  window.onblur = blur;
@@ -25,8 +23,68 @@
25
23
  ```
26
24
  どうやれば右クリックをこれの例外として扱えるのか教えてほしいです。
27
25
 
26
+ ### テスト環境で使っているphpファイル
27
+ ```php
28
+ <!doctype html>
29
+ <html>
30
+ <head>
31
+ <meta charset="UTF-8">
32
+ <title>show_pic test</title>
33
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
34
+ <meta name="viewport" content="width=device-width, initial-scale=1">
35
+ <meta http-equiv="Pragma" content="no-cache">
36
+ <meta http-equiv="Cache-Control" content="no-cache">
37
+
38
+ <script>
39
+
40
+ //インターバル使ってコンテクストメニューのループ
41
+ function resetDisableCon(){
42
+ document.oncontextmenu = function () {return false;}
43
+ document.getElementsByTagName('html')[0].oncontextmenu = function () {return false;}
44
+ document.body.oncontextmenu = function () {return false;}
45
+ }
46
+
47
+ setInterval("resetDisableCon()", 100);
48
+
49
+
50
+ //blurイベント ブラウザのfocusが2回外れたときにリロード(右クリックもfocus外れる対象で要改善)
51
+ window.onblur = blurEvent;
52
+ var n=0;
53
+ function blurEvent() {
54
+ n++;
55
+ if(n>=2){
56
+ location.reload();
57
+ // alert("blur event detected!");
58
+ window.onblur = '';
59
+ }}
60
+
61
+ //windows、macのctrl shift altスクショとかのキー検出でリロード
62
+ document.addEventListener('keydown', (event) => {
63
+
64
+ if (event.shiftKey == true || event.ctrlKey == true || event.altKey == true) {
65
+ location.reload();
66
+ // alert("keydown detected!");
67
+ }}, false);
68
+
69
+
70
+ document.addEventListener('keyup', (event) => {
71
+
72
+ if (event.shiftKey == false && event.ctrlKey == false && event.altKey == false) {
73
+ location.reload();
74
+
75
+ }}, false);
76
+ </script>
77
+ </head>
78
+ <body>
79
+
80
+ <main>
81
+ <img src="image.jpg" class="image">
82
+ </main>
83
+
84
+ </body>
85
+ </html>
86
+ ```
87
+
28
88
  ### 試したこと
29
89
  document.addEventListener("mousedown", function(){
30
- を使おうとしたがよく分からず終了
90
+ を使おうとしたがよく分からず終了
31
-
32
- 初歩的な質問ですみません!よろしくお願いします!