缺少 iframe ie8.相对定位不能解决问题

Missing iframe ie8. Relative positioning doesn't resolve issue

本文关键字:不能 解决问题 定位 相对 iframe ie8 缺少      更新时间:2023-09-26

我正在使用他们的PHP和Javascript在网站上实现第三方2fa解决方案(Duo Web)。
我让它适用于所有浏览器,但 IE8 除外。
通过初始登录屏幕后,将加载2fa登录页面,并且应该具有2fa提示的iframe为空。

在阅读了一些线程之后,似乎 ie8 中 iframe 的正常解决方案是从嵌入页面中删除相对位置或将其提供给 iframe。
由于我无法访问该页面,因此我向框架添加了相对定位,但没有效果。 这是奇怪的部分,这只发生在您第一次访问 2fa 页面时。

重新加载页面会正确显示 iframe。 代码似乎也存在。 Duo 中有一个选项,可以在到达 2fa 页面时自动发送登录请求。 启用此功能后,请求将显示在 Duo 应用中,即使 iframe 为空,您也可以正确登录。

所以看起来代码有效,iframe 只是空白。 同样,这仅在第一次访问页面时发生。 之后,iframe 将正确显示,直到浏览器关闭并重新打开。

由于这与工作相关,我无法显示确切的代码,但它基本上是

<div id="iframe_container" style="text-align:center;width:100%;">
    <iframe id="duo_iframe" frameborder="0">Loading...</iframe>
    // this form passes data along when response comes back
    <form method="POST" id="duo_form"> 
        <input type="hidden"/>
        <input type="checkbox"/><label for="checkbox"><small>Remember this device</small></label>
    </form>
    // form to log user out and send them back to normal login page
    <form method="GET" action="url">
        <input type="hidden" />
        <input type="hidden" />
        <input type="submit" id="submit" value="Go Back">
    </form>
</div>

CSS如下

#duo_iframe
{
    width: 100%;
    min-width: 304px;
    max-width: 620px;
    height: 330px;
    background: transparent;
    position: relative;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

我正在兼容模式下运行,但禁用它并不能解决问题。 任何想法将不胜感激。

原来是竞争条件。 当第一次加载嵌入页面时,它的初始化Javascript在元素可用之前触发。 刷新主页时,嵌入的内容将被缓存,以便在触发 js 之前加载。 添加在几秒钟后调用 init 函数的超时可以解决此问题。