【发布时间】:2017-03-14 18:58:41
【问题描述】:
我正在使用隐藏的 iframe 在后台刷新页面以保持访问令牌的最新状态,而无需刷新整个页面。这在除 IE 之外的所有浏览器中都非常有效,在 IE 中,当刷新发生时,IE 会从桌面上的任何内容中窃取焦点。所以我的问题是隐藏 iframe 的 ajax 替代方案还是更好的处理方法?这是我的代码:
<iframe Id="hidden" src="https://www.xxxxxxxx.com"
style="visibility: hidden;
position: absolute;
left: 0; top: 0;
height:100%; width:0;
border: none;"
onload="refresh()">
</iframe>
<script>
function refresh() {
console.clear();
setTimeout(refreshCookie, 60000);
function refreshCookie() {
document.getElementById('hidden').src = document.getElementById('hidden').src;
};
};
</script>
【问题讨论】:
-
其他页面是否在不同的域中?如果是,那么您将遇到跨域问题。
标签: javascript jquery html ajax iframe