我得到了我的roku远程控制脚本的网络控制台错误。javascript如下所示:
<script>
function rokuSend(RokuAccess) {
xhr = new XMLHttpRequest();
xhr.onload=function() { alert(xhr.responseText); }
xhr.open("POST", RokuAccess);
xhr.send();
}
function rokuKeySend(keyVal) {
rokuSend("http://" + document.getElementById('RokuIP').value + ":8060/keypress/" + keyVal);
}我使用以下方式为Roku提供IP地址:
<form id="Roku"><input type="text" id="RokuIP"></form>当我按下一个键在我的网络上基于远程它发送一个命令,以简化事情,我将使用相同的功能,以发送按键以及其他命令。因此,其中一个名为"rokuKeySend()“的函数只需构造发送键按下发出的命令所需的正确字符串。第二个函数将命令"rokuSend()"sends给Roku。稍后,将发送其他命令从Roku收集数据,因此我将创建更多使用"rokuSend()“的函数。现在,我使用以下按钮(这些按钮稍后将被图像替换),因为它们现在可以很好地作为概念的证明:
<button type="button" onclick="rokuKeySend('Back')">Back</button>
<button type="button" onclick="rokuKeySend('Home')">Home</button>
<button type="button" onclick="rokuKeySend('Up')">Up</button>
<button type="button" onclick="rokuKeySend('Left')">Left</button>
<button type="button" onclick="rokuKeySend('Select')">Select</button></td>
<button type="button" onclick="rokuKeySend('Right')">Right</button>
<button type="button" onclick="rokuKeySend('Down')">Down</button>
<button type="button" onclick="rokuKeySend('InstantReplay')">InstantReplay</button>
<button type="button" onclick="rokuKeySend('Info')">Info</button>
<button type="button" onclick="rokuKeySend('Rev')">Rev</button>
<button type="button" onclick="rokuKeySend('Play')">Play</button>
<button type="button" onclick="rokuKeySend('Fwd')">Fwd</button>
<button type="button" onclick="rokuKeySend('Backspace')">Backspace</button>
<button type="button" onclick="rokuKeySend('Search')">Search</button>
<button type="button" onclick="rokuKeySend('Enter')">Enter</button>在将IP放入表单的输入后,我可以按任意一个按钮,它们都可以工作。然而,当鼠标点击时,它们会“视觉”地抑制,但不会从抑郁状态返回。在检查浏览器的web控制台时,我发现了一个错误。这个错误很可能是我没有从抑郁状态返回的原因。我该怎么解决这个问题?错误列于下:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://xxx.xxx.xxx.xxx/keypress/KEY. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).在上面的错误中,'xxx‘表示IP,' key’表示按下的键。
https://stackoverflow.com/questions/65221761
复制相似问题