anan66 commited on
Commit
f0ae3de
·
1 Parent(s): 7010a0b

upload matchn game

Browse files
Files changed (1) hide show
  1. matchn/MatchNGame.html +19 -0
matchn/MatchNGame.html CHANGED
@@ -144,6 +144,25 @@
144
  <script type="text/javascript" src="./gameapp.js"></script>
145
  </head>
146
  <body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  <canvas id='canvas'>
148
  HTML5 canvas appears to be unsupported in the current browser.<br />
149
  Please try updating or use a different browser.
 
144
  <script type="text/javascript" src="./gameapp.js"></script>
145
  </head>
146
  <body>
147
+ <script>
148
+ // 捕获安卓返回键
149
+ document.addEventListener("backbutton", function () {
150
+ if (confirm("确定要退出游戏吗?")) {
151
+ // 关闭当前页面
152
+ window.close();
153
+ }
154
+ }, false);
155
+
156
+ // 捕获浏览器返回操作
157
+ window.addEventListener("popstate", function (event) {
158
+ if (confirm("确定要退出游戏吗?")) {
159
+ window.history.go(-1); // 返回上一页
160
+ } else {
161
+ // 阻止返回操作
162
+ window.history.pushState(null, null, window.location.href);
163
+ }
164
+ });
165
+ </script>
166
  <canvas id='canvas'>
167
  HTML5 canvas appears to be unsupported in the current browser.<br />
168
  Please try updating or use a different browser.