2012-09-18 53 views
0

我有一个旧网站,它已被两个网站取代,并开始制作一个模式窗口,以指导人们访问正确的网站。jQuery模式窗口不能在Internet Explorer中工作

我只能在旧网站上提供HTML文件,并且HTML的结构不是很统一。我决定在文档的头部添加一些jQuery,它为页面添加了一个模式窗口,为人们提供了到新网站的链接。

这一切都适用于Linux和Mac上的Chrome,Safari和Firefox,但在PC上的Internet Explorer上测试时,它看起来都是错误的,根本不起作用。我打开了控制台,并没有错误。

$(function(){ 
    var disappear = function(){ 
     // window.location = window.location 
     var $m = $('.modal') 
     $m.eq(0).fadeOut() 
     $m.hide('slow') 
    } 
    $('body').append(
     $("<div class='modal'>").css({ 
     position: 'fixed', 
     width: '100%', 
     height: '100%', 
     backgroundColor: '#000', 
     opacity: .8, 
     top: 0, 
     left: 0 
     })).click(disappear).after($("<div class='modal'>").css({ 
     position: 'fixed', 
     width: 600, 
     // height: 300, 
     backgroundColor: '#FFE', 
     borderRadius: 10, 
     border: "5px solid #005400", 
     top: '10%', 
     left: '50%', 
     marginLeft: -300, 
     padding: '1em', 
     fontFamily: 'trebuchet ms, sans-serif' 
     }).html("<h2>Please be advised</h2><p>\ 
The information on this website is maintained for historical purposes.<br>\ 
It has not been updated since 2009.<br>\ 
However, Tesfa Community Tourism continues to thrive.<br>\ 
<h3>For up to date information...</h3>\ 
<a href='http://tesfatours.com/?from=cbtcom' class='button green'>Book with Tesfa Tours</a>\ 
<a href='http://community-tourism-ethiopia.org/?from=cbtcom' class='button sand'>Community website</a>\ 
<a href='#' id='close' class='button'>Continue to archive site</a>\ 
</p>\ 
")) 
    $('#close').css({fontSize:'12px'}).live('click',disappear); 
    $('table table').eq(1).html(myString) 
    }) 

任何想法,为什么这种失败赞赏。

回答

0

这通常是与IE发生时,你忘记了一个小角色像逗号(,)或分号(;)或大括号({ })。无论你在上面的代码中写了什么,我已经检查过这是正确的,但在其他一些情况下,你必须检查所有功能。

我也面临这种类型的问题,我想念一个功能。在我看来,让我们有这样的支票:

$('#close').css({fontSize:'12px'}).live('click',disappear); 
    $('table table').eq(1).html(myString) 
}); 

我在最后添加了一个分号。

+0

这可能是正确的 - 但是我现有的页面继承了太多糟糕的代码 - 将内容复制出来并从头开始会更容易 - 所以我绝对不会知道。 –

0

尝试在你的CSS使用这个,让我然后知道 -

filter:alpha(opacity=80); 
opacity: 0.8; 
+0

感谢您的建议,但我相当确信这不是问题。淡出效果很好,但灰色表格的位置是错误的,第二个div没有附加。我实际上认为jQuery可以完成你在幕后推荐的内容(在检测到浏览器后使用其中一种方法)。不管怎么说,还是要谢谢你。 –

相关问题