NhungGame.txt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Game</title>
  6. </head>
  7. <body style="margin:0">
  8. @* Kích ho?ch HTML5 v?i tham s? truy?n san construct 3 trên url *@
  9. @* <iframe id="gameFrame"
  10. src="@root/DragDrop/index.html?gameType=0&msisdn=09&token=1234567890&transId=1234567"
  11. style="
  12. width:100%;
  13. height:100vh;
  14. border:none;
  15. display:block;
  16. ">
  17. </iframe> *@
  18. <iframe id="gameFrame"
  19. src="@root/DragDrop/index.html"
  20. style="
  21. width:100%;
  22. height:100vh;
  23. border:none;
  24. display:block;
  25. ">
  26. </iframe>
  27. @* Ðo?n Js nh?n k?t qu? t? construct 3 v? *@
  28. <script>
  29. const frame = document.getElementById("gameFrame");
  30. console.log("MVC bat dau gui du lieu vao trong construct 3");
  31. window.addEventListener(
  32. "message",
  33. function (event)
  34. {
  35. console.log("Ðây là hàm l?ng nghe s? kiên t? construct 3 d?y ra MVC nhé!!!!!!");
  36. console.log(event.data);
  37. //Khi trong construct 3 g?i ra s? ki?n này thì t?c là trong Construc 3
  38. if (event.data.type === "GAME_READY")
  39. {
  40. console.log("Gui INIT_GAME");
  41. //Khi da nhan duoc su kien nay tu trong Construct 3 gui ra thi
  42. // chung ta construct 3 da listener thanh cong
  43. //Tien hanh gui cac thong so duoi vao construct3
  44. frame.contentWindow.postMessage({
  45. type: "INIT_GAME",
  46. gameType: "Easy",
  47. msisdn: "09",
  48. token: "1234567890",
  49. transId: "1234567890",
  50. root: "@root"
  51. }, "*");
  52. }
  53. }
  54. );
  55. </script>
  56. </body>
  57. </html>