Guest User

Untitled

a guest
Feb 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.37 KB | None | 0 0
  1. why i am not being directed to game.html after clicking on the buttons?
  2. The
  3. file Structure is server/server.js, public/index.html,public/game.html.
  4. index.html
  5.  
  6. < !DOCTYPE html>
  7.  
  8. <html>
  9.  
  10. <title>QUIZ GAME</title>
  11.  
  12.  
  13. <meta charset="UTF-8">
  14.  
  15. <meta name="viewport" content="width=device-width, initial-scale=1">
  16.  
  17. <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  18.  
  19. <body>
  20.  
  21. <!-- Navbar (sit on top) -->
  22.  
  23. <div class="w3-top">
  24.  
  25. <div class="w3-bar w3-white w3-wide w3-padding w3-card">
  26.  
  27. <a href="#home" class="w3-bar-item w3-button"><b>QUIZ</b>Book</a>
  28.  
  29. <!-- Float links to the right. Hide them on small screens -->
  30.  
  31. <div class="w3-right w3-hide-small">
  32.  
  33. <a href="#projects" class="w3-bar-item w3-button">CATEGORIES</a>
  34.  
  35. <a href="#about" class="w3-bar-item w3-button">About</a>
  36.  
  37. <a href="#contact" class="w3-bar-item w3-button">Contact</a>
  38.  
  39. </div>
  40.  
  41. </div>
  42.  
  43. </div>
  44.  
  45. <!-- Header -->
  46.  
  47.  
  48. <header class="w3-display-container w3-content w3-wide" style="max-
  49.  
  50. width:1500px;" id="home">
  51.  
  52. <img class="w3-image" src="pics/quiz.jpg" alt="Architecture" width="1500"
  53.  
  54. height="800">
  55.  
  56. <div class="w3-display-middle w3-margin-top w3-center">
  57.  
  58. <h1 class="w3-xxlarge w3-text-white"><span class="w3-padding w3-black w3-
  59.  
  60. opacity-min"><b>QUIZ</b></span> <span class="w3-hide-small w3-text-light-
  61.  
  62. grey">Book</span></h1>
  63.  
  64.  
  65. </div>
  66.  
  67. </header>
  68.  
  69. <!-- Page content -->
  70.  
  71. <div class="w3-content w3-padding" style="max-width:1564px">
  72.  
  73. <!-- Project Section -->
  74.  
  75. <div class="w3-container w3-padding-32" id="projects">
  76.  
  77. <h3 class="w3-border-bottom w3-border-light-grey w3-padding-
  78.  
  79. 16">CATEGORIES</h3>
  80.  
  81. </div>
  82.  
  83. <div class="w3-row-padding">
  84.  
  85. <div class="w3-col l3 m6 w3-margin-bottom">
  86.  
  87. <div class="w3-display-container">
  88.  
  89. <button class="w3-button w3-hover-black" ><img src="pics/GK.jpg"
  90.  
  91. alt="House" style="width:100%"><div class="content">
  92.  
  93. <h3>GENERAL KNOWLEDGE</h3></div></button>
  94.  
  95. </div>
  96.  
  97. </div>
  98.  
  99. <div class="w3-col l3 m6 w3-margin-bottom">
  100.  
  101. <div class="w3-display-container">
  102.  
  103. <button class="w3-button w3-hover-black"><img src="pics/maths_school.jpg"
  104.  
  105.  
  106. alt="House" style="width:100%"> </button>
  107.  
  108. </div>
  109.  
  110. </div>
  111.  
  112. <div class="w3-col l3 m6 w3-margin-bottom">
  113.  
  114. <div class="w3-display-container">
  115.  
  116. <button class="w3-button w3-hover-black"><img src="pics/bollywood.jpg"
  117.  
  118. alt="House" style="width:100%"> </button>
  119.  
  120.  
  121.  
  122. </div>
  123.  
  124. </div>
  125.  
  126. <div class="w3-col l3 m6 w3-margin-bottom">
  127.  
  128. <div class="w3-display-container">
  129.  
  130. <button class="w3-button w3-hover-black"><img
  131.  
  132. src="pics/hollywood.jpg" alt="House" style="width:100%"> </button>
  133.  
  134.  
  135.  
  136. </div>
  137.  
  138. </div>
  139.  
  140. </div>
  141.  
  142.  
  143.  
  144. <div class="w3-row-padding">
  145.  
  146. <div class="w3-col l3 m6 w3-margin-bottom">
  147.  
  148. <div class="w3-display-container">
  149.  
  150. <button class="w3-button w3-hover-black"><img src="pics/cricket.jpg"
  151.  
  152. alt="House" style="width:99%"> </button>
  153.  
  154.  
  155. </div>
  156.  
  157. </div>
  158.  
  159. <div class="w3-col l3 m6 w3-margin-bottom">
  160.  
  161. <div class="w3-display-container">
  162.  
  163. <button class="w3-button w3-hover-black"> <img src="pics/football.jpg"
  164.  
  165. alt="House" style="width:99%"></button>
  166.  
  167. </div>
  168.  
  169. </div>
  170.  
  171. <div class="w3-col l3 m6 w3-margin-bottom">
  172.  
  173. <div class="w3-display-container">
  174.  
  175. <button class="w3-button w3-hover-black"> <img src="pics/sports.jpg"
  176.  
  177. alt="House" style="width:99%"> </button>
  178.  
  179. </div>
  180.  
  181. </div>
  182.  
  183. <div class="w3-col l3 m6 w3-margin-bottom">
  184.  
  185. <div class="w3-display-container">
  186.  
  187. <button class="w3-button w3-hover-black"> <img src="pics/science.png"
  188.  
  189. alt="House" style="width:99%"> </button>
  190.  
  191. </div>
  192.  
  193. </div>
  194.  
  195. <div class="w3-col l3 m6 w3-margin-bottom">
  196.  
  197. <div class="w3-display-container">
  198.  
  199. <button class="w3-button w3-hover-black"><img src="pics/history.jpg"
  200.  
  201. alt="House" style="width:99%"> </button>
  202.  
  203. </div>
  204.  
  205. </div>
  206.  
  207. <div class="w3-col l3 m6 w3-margin-bottom">
  208.  
  209. <div class="w3-display-container">
  210.  
  211. <button class="w3-button w3-hover-black"> <img src="pics/music.png"
  212.  
  213. alt="House" style="width:99%"> </button>
  214.  
  215. </div>
  216.  
  217. </div>
  218.  
  219. <div class="w3-col l3 m6 w3-margin-bottom">
  220.  
  221. <div class="w3-display-container">
  222.  
  223. <button class="w3-button w3-hover-black"> <img src="pics/tennis.jpg"
  224.  
  225. alt="House" style="width:99%"> </button>
  226.  
  227. </div>
  228.  
  229. </div>
  230.  
  231. </div>
  232.  
  233.  
  234. <!-- About Section -->
  235.  
  236. <div class="w3-container w3-padding-32" id="about">
  237.  
  238. <h3 class="w3-border-bottom w3-border-light-grey w3-padding-16">About</h3>
  239.  
  240. </div>
  241.  
  242.  
  243.  
  244. <!-- Contact Section -->
  245.  
  246. <div class="w3-container w3-padding-32" id="contact">
  247.  
  248. <h3 class="w3-border-bottom w3-border-light-grey w3-padding-
  249.  
  250. 16">Contact</h3>
  251.  
  252. <p>Lets get in touch and talk about your and our next project.</p>
  253.  
  254. <form action="/" target="_blank">
  255.  
  256. <input class="w3-input" type="text" placeholder="Name" required
  257.  
  258. name="Name">
  259.  
  260. <input class="w3-input w3-section" type="text" placeholder="Email" required
  261.  
  262. name="Email">
  263.  
  264. <input class="w3-input w3-section" type="text" placeholder="Subject"
  265.  
  266. required name="Subject">
  267.  
  268. <input class="w3-input w3-section" type="text" placeholder="Comment"
  269.  
  270. required name="Comment">
  271.  
  272. <button class="w3-button w3-black w3-section" type="submit">
  273.  
  274. <i class="fa fa-paper-plane"></i> SEND MESSAGE
  275.  
  276. </button>
  277.  
  278. </div>
  279.  
  280. </div>
  281.  
  282. <script>
  283.  
  284. document.getElementsByClassName('w3-button w3-hover-black').onclick =
  285.  
  286. function(){
  287.  
  288. window.location.href = "https://localhost:3000/game.html";
  289.  
  290. }
  291.  
  292. </html>
  293.  
  294.  
  295.  
  296. in game.html
  297.  
  298. <!DOCTYPE html>
  299.  
  300. <html>
  301.  
  302. <head>
  303.  
  304. <meta charset="utf-8" />
  305.  
  306. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  307.  
  308. <title>QUIZ book</title>
  309.  
  310. <meta name="viewport" content="width=device-width, initial-scale=1">
  311.  
  312. <link rel="stylesheet" type="text/css" media="screen" href="main.css" />
  313.  
  314. </head>
  315.  
  316. <body>
  317.  
  318. <div id = "gameDiv"></div>
  319.  
  320. <script src = "/socket.io/socket.io.js"></script>
  321.  
  322. <script src = "lib/phaser.min.js"></script>
  323.  
  324. <script src = "main.js"></script>
  325.  
  326. <script src = "player.js"></script>
  327.  
  328. </body>
  329.  
  330. </html>
  331.  
  332.  
  333. in server/server.js
  334.  
  335. var express = require('express');
  336.  
  337. var socketIo = require('socket.io');
  338.  
  339. var path = require('path');
  340.  
  341. var http = require('http');
  342.  
  343. var app = express();
  344.  
  345. const port = process.env.PORT ||3000 ;
  346.  
  347. const pathjoin = path.join(__dirname, '../public');
  348.  
  349. const pathjoin1 = path.join(__dirname,'../public/game.html');
  350.  
  351. var server = http.createServer(app);
  352.  
  353. app.use(express.static(pathjoin));
  354.  
  355. app.use('/game.html',express.static(pathjoin1));
  356.  
  357. var io = socketIo(server);
  358.  
  359. io.on('connection',(socket)=>{
  360.  
  361. console.log('user connected ' + socket.id);
  362.  
  363. });
  364.  
  365.  
  366.  
  367.  
  368.  
  369. server.listen(port,()=>{
  370.  
  371. console.log('server started');
  372.  
  373. });
Add Comment
Please, Sign In to add comment