繁体   English   中英

jQuery模式窗口在Internet Explorer中不起作用

[英]jQuery modal window not working in internet explorer

我有一个旧的网站,该网站已被两个网站取代,并开始制作一个模式窗口,以引导人们访问正确的网站。

我只能在旧站点上提供HTML文件,并且HTML的结构不是很统一。 我决定在文档的开头添加一些jQuery,从而在页面上添加一个模式窗口,使人们可以链接到新站点。

这一切在Linux,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)
  })

关于为什么失败的任何想法都值得赞赏。

尝试在CSS中使用它,然后让我知道-

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

当您忘记诸如逗号(,)或分号(;)或花括号({ })类的小字符时,这通常在IE中发生。 无论您用上面的代码写过什么,我都检查过这是正确的,但是在其他情况下,您必须检查所有功能。

我也遇到过这类问题,我在一个函数中错过了。 在我看来,让我们进行如下检查:

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

我最后加了一个分号。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM