jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – Internet Explorer和Very Strange iFrame行为的情况大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在开发一个带有窗口系统的Internet Explorer,我真的有一个真正的… bizzare错误.基本上,窗口绝对定位div包含啊iFrame,显示他们的页面并随之调整大小.在所有其他浏览器中,这可以正常工作,但在IE中,iFrame没有正确显示.

生成新窗口的原始代码如下所示:

function spawnNewWindow(url,title,typE)
{
    //Does another window with that particular type already exist?
    //If so,just point it at the new link without actually spawning a new window.
    var cancelSpawn = false;
    if ( $('.windowType_'+typE).length )
    {
        //@R_674_9531@e the SRC attribute for the iframe contained within the window. This should effectively
        //reload the window too.
        $('.windowType_'+typE).children("iframe").attr("src","/darknova4/"+url);
    } else {


    //First,create the window
    $("body").append(
    "<div class='window'> \
    <div class='resizeArea'></div> \
    <div class='titlebar'>"+title+"</div> \
    <div class='closeWindow'></div> \
    <div class='windowContent newspawn'><iframe src='/darknova4/"+url+"' frameborder='0' width='100%' height='100%' scrolling='auto'></iframe></div> \
    </div>");

    //Move this window to the top of the stack
    $(".newspawn").parent(".window").css("z-index",windowZIndex++);

    //Set the data for this window's type,will be used to prevent copy windows being open later
    $(".newspawn").addClass("windowType_"+typE);

    //Set up the window for moving and resizing and other stuff
    setupWindows();

    //Finally,remove the "newspawn" flag from the window,since it has content and we don't need work with it anymore.
    $(".newspawn").removeClass("newspawn");

    }
}

在Internet Explorer上,这会生成一个空白的白色窗口,指示一个不可见的iFrame,因为我的所有窗口页面都有黑色背景.我怀疑着名的(并且仍然不太固定)z-index错误,所以@R_7_10673@下更改来使用堆叠顺序,看看我是否能找到快速修复:

$("body").append(
"<div class='window'> \
<div class='resizeArea'></div> \
<div class='titlebar'>"+title+"</div> \
<div class='closeWindow'></div> \
<div class='windowContent newspawn'><iframe style='position: relative;' src='/darknova4/"+url+"' frameborder='0' width='100%' height='100%' scrolling='auto'></iframe></div> \
</div>");

注意相对位置,它应该是对象的认位置,但不是因为堆叠错误.这段代码会发生什么,窗口显示,iFrame显示,所有看起来都很好,直到你尝试使用它.我无法解释原因,但Mousing over iFrame导致它消失.我没有与鼠标移动事件绑定的网站上的代码,并且iFrame页面上没有任何代码会导致它在鼠标悬停时执行任何操作.这真的很奇怪.有没有人知道为什么它可能会这样表现?

如果你需要亲自看看这个行为,我已经测试了在www.darknovagames.com上实现的系统,它在firefox中运行良好,但正如所提到的那样在IE中真的很棒.如果您认为它会有所帮助,我可以发布更多代码,但这是我认为错误的地方.也就是说,我很乐意在父窗口上发布CSS,为我的鼠标事件发布JavaScript等.

感谢任何能够对这种奇怪行为提供一些见解的人.

解决方法

尝试从iframe中的HTML元素中删除position:relative.这似乎解决了IE8(以及IE8的兼容模式)中的问题.

更新:修复高度问题

添加位置:绝对;左:0px;顶部:0px;底部:0px;右:0px;到iframe修复了由上述位置引起的高度问题:IE7和IE8的相对变化.

有了这两个修复程序,iframe似乎在我的机器上模拟IE7的IE7,IE8和IE8中正常工作.

大佬总结

以上是大佬教程为你收集整理的jquery – Internet Explorer和Very Strange iFrame行为的情况全部内容,希望文章能够帮你解决jquery – Internet Explorer和Very Strange iFrame行为的情况所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。