web.html 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>CocoBlockly CocoPi – CocoRobo CocoPi Module</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <meta http-equiv="Content-Type" content="text/html; scharset=UTF-8">
  8. <meta name="theme-color" content="#2C4FCD">
  9. <style>
  10. *{
  11. box-sizing: border-box;
  12. }
  13. body{
  14. width: 100%;
  15. height: 100vh;
  16. margin: 0;
  17. }
  18. #iframeDiv{
  19. display: flex;
  20. flex-flow: wrap;
  21. /* justify-content: space-evenly; */
  22. }
  23. #iframeDiv img{
  24. width: 25%;
  25. /* height: 360px; */
  26. padding: 5px;
  27. }
  28. input{
  29. padding: 7px;
  30. font-size: 1rem;
  31. outline: none;
  32. }
  33. button{
  34. margin-left: 10px;
  35. color: #fff;
  36. border: none;
  37. border-radius: 2px;
  38. display: inline-block;
  39. height: 36px;
  40. line-height: 36px;
  41. padding: 0 16px;
  42. text-transform: uppercase;
  43. vertical-align: middle;
  44. -webkit-tap-highlight-color: transparent;
  45. background-color: #2196F3;
  46. cursor: pointer;
  47. }
  48. </style>
  49. </head>
  50. <body>
  51. <div id="iframeDiv">
  52. <!-- <iframe src="http://192.168.43.193:18811" scrolling="no"></iframe> -->
  53. </div>
  54. <div style="margin: 20px auto;text-align: center;">
  55. <input type="text" id="httpSrc" placeholder="">
  56. <button onclick="addIframe()">添加</button>
  57. </div>
  58. </body>
  59. <script>
  60. function addIframe(){
  61. var iframeDiv = document.getElementById("iframeDiv");
  62. var httpSrc = document.getElementById("httpSrc").value;
  63. let createIframe = document.createElement("img")
  64. createIframe.scrolling = "no"
  65. console.log(httpSrc)
  66. if(httpSrc){
  67. createIframe.src = `http://${httpSrc}:18811`
  68. console.log(createIframe)
  69. // createIframe.onload=function(){
  70. // }
  71. iframeDiv.appendChild(createIframe)
  72. document.getElementById("httpSrc").value = ""
  73. }
  74. }
  75. </script>
  76. </html>