プログラム初心者です。
MonacadeでiPhone用のTCP通信ができるアプリを作成したいのです。
"sockets-for-cordova"を通ろくしてカスタムビルドデバッガーを実施したところ
"Can't find variable:Socket"のエラーがかえって来ています。
対処法わかる方教えてください。
index.HTML
<!DOCTYPE HTML> <html lang="ja"> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover"> <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'"> <script src="components/loader.js"></script> <script src="lib/onsenui/js/onsenui.min.js"></script> <link rel="stylesheet" href="components/loader.css"> <link rel="stylesheet" href="lib/onsenui/css/onsenui.css"> <link rel="stylesheet" href="lib/onsenui/css/onsen-css-components.css"> <link rel="stylesheet" href="css/style.css"> <script style="text/javascript" src="jquery/dist/jquery.min.map"></script> <script> // Page init event document.addEventListener('init', function(event) { var page = event.target; if (page.matches('#first-page')) { page.querySelector('#push-button').onclick = function() { document.querySelector('#navigator').pushPage('page2.html'); }; } else if (page.matches('#second-page')) { page.querySelector('#pop-button').onclick = function() { document.querySelector('#navigator').popPage(); }; } }); if (ons.platform.isIPhoneX()) { document.documentElement.setAttribute('onsflag-iphonex-portrait', ''); document.documentElement.setAttribute('onsflag-iphonex-landscape', ''); } //Cordova起動中 document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { alert('Cordova is ready!'); } </script> </head> <body> <script type='text/javascript' src="js/jquery-3.6.0.min.js"></script><!--★★★★--> <script> var socket = new Socket(); socket.open( "http://x.x.x.x", 8500, function() { alart('connect!') // invoked after successful opening of socket }, function(errorMessage) { alert('not connect!') // invoked after unsuccessful opening of socket }); </script> <ons-navigator id="navigator" page="page1.html"></ons-navigator> <!--Page1-------------------------------------------------------------------------------------> <ons-template id="page1.html"> <ons-page id="first-page"> <ons-toolbar> <div class="center">P1</div> </ons-toolbar></ons-template> ```<div class="content" style="text-align: center"> <p </p> <ons-button id="push-button">P2</ons-button> <br><br> <div id="text-button1" onclick="clickDisplayAlert(3)">1</div> <br> <div id="text-button1" onclick="clickDisplayAlert(5)">2</div> <br><br> </div> </ons-page>
あなたの回答
tips
プレビュー