我正在使用带 STM32F4 的 lwip tcp/ip 堆栈为我的设备托管一个小型配置网站。我正在刷新页面上隐藏的 iframe 以获取更新的 SSI 值,然后在我的 tmp 变量中使用它们来更新图表。下面的代码在 IE 中运行良好,但在 Firefox 和 Chrome 中 tmp 仅获取一次值,即使 temptemp 元素正在从我的固件中获取更新值。
var iframe = document.getElementById("iframeID");
var innerdoc = (iframe.contentWindow || iframe.contentDocument);
if(innerdoc.document)innerdoc = innerdoc.document;
(function worker() {
$.ajax({
url: 'data.shtml',
complete: function() {
document.getElementById("iframeID").contentWindow.location.reload();
setTimeout(worker, 1000);
tmp = innerdoc.getElementById("temptemp").value;
}
});
})();
最佳答案
“域、协议(protocol)和端口必须匹配。”
在 Firefox 和 Chrome 中运行时,您是否检查过控制台是否有错误?我想你被告知你不能访问不安全的 JavaScript。也许 Internet Explorer 对它运行 JavaScript 的方式不安全就可以了。
关于javascript - 从适用于 IE 但不适用于 Chrome 或 Firefox 的 iframe 中获取值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27736604/