新規プロジェクトでおみくじアプリテンプレート使って作成し、
html
1<!DOCTYPE HTML>
2<html>
3<head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
6 <meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
7 <script src="components/loader.js"></script>
8 <link rel="stylesheet" href="components/loader.css">
9
10 <script>
11 function omikuji (){
12 var dice = Math.floor(Math.random() * 3);
13 var image_name;
14 if (dice == 0) {
15 image_name = "omikuji-daikichi.png";
16 } else if (dice == 1) {
17 image_name = "omikuji-chuukichi.png";
18 } else {
19 image_name = "omikuji-hei.png";
20 }
21
22 navigator.vibrate(2000);
23
24 document.getElementById("saisyo").style["display"] = "none";
25 document.getElementById("kekka").src = "images/" + image_name;
26 document.getElementById("kekka").style["display"] = "inline";
27 document.getElementById("button").src = "images/omikuji-btn-yarinaosu.png";
28 }
29 </script>
30 <style>
31 body {
32 background-image: url("images/omikuji-bg.png");
33 background-size: cover;
34 background-repeat: no-repeat;
35 margin: 0;
36 padding: 0;
37 text-align: center;
38 }
39 #hako {
40 margin-top: 15%;
41 margin-left : 0;
42 margin-right : 0;
43 }
44
45 img {
46 width: 70%;
47 }
48
49 #bottombar {
50 position: absolute;
51 bottom: 30px;
52 width: 100%;
53 }
54 </style>
55</head>
56<body>
57 <div id="hako">
58 <img id="saisyo" src="images/omikuji-box.png" />
59 <img id="kekka" style="display : none;"/>
60 </div>
61 <div id="bottombar">
62 <img id="button" src="images/omikuji-btn-hajimeru.png" onclick="omikuji()">
63 </div>
64</body>
65</html>
66
でAndroidでMonacaDebuggerから起動したらバイブレーションしたのですが、機種依存なのかなぁ
(私のはHUAWEI P20 liteです)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/15 15:02
2019/01/16 02:47
2019/01/21 15:26