Nic*_*ynt 5 html css iframe jquery
我正在开发一个带有窗口系统的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 )
{
//Update 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");
}
}
Run Code Online (Sandbox Code Playgroud)
在Internet Explorer上,这会生成一个空白的白色窗口,指示一个不可见的iFrame,因为我的所有窗口页面都有黑色背景.我怀疑着名的(并且仍然不太固定)z-index错误,所以我做了以下更改来使用堆叠顺序,看看我是否能找到快速修复:
$("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>");
Run Code Online (Sandbox Code Playgroud)
注意相对位置,它应该是对象的默认位置,但不是因为堆叠错误.这段代码会发生什么,窗口显示,iFrame显示,所有看起来都很好,直到你尝试使用它.我无法解释原因,但Mousing over iFrame导致它消失.我没有与鼠标移动事件绑定的网站上的代码,并且iFrame页面上没有任何代码会导致它在鼠标悬停时执行任何操作.这真的很奇怪.有没有人知道为什么它可能会这样表现?
如果你需要亲自看看这个行为,我已经测试了在www.darknovagames.com上实现的系统,它在firefox中运行良好,但正如所提到的那样在IE中真的很棒.如果您认为它会有所帮助,我可以发布更多代码,但这是我认为错误的地方.也就是说,我很乐意在父窗口上发布CSS,为我的鼠标事件发布JavaScript等.
感谢任何能够对这种奇怪行为提供一些见解的人.
Ste*_*rds 12
尝试position: relative从iframe中的HTML元素中删除.这似乎解决了IE8(以及IE8的兼容模式)中的问题.
更新:修复高度问题
添加position: absolute; left: 0px; top: 0px; bottom: 0px; right: 0px;到iframe修复了由position: relativeIE7和IE8中的上述更改引起的高度问题.
有了这两个修复程序,iframe似乎在我的机器上模拟IE7的IE7,IE8和IE8中正常工作.
| 归档时间: |
|
| 查看次数: |
11501 次 |
| 最近记录: |