简体   繁体   English

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

[英]jQuery modal window not working in internet explorer

I have an old website, which has been replaced by two websites, and went about making a modal window to guide people to the correct site. 我有一个旧的网站,该网站已被两个网站取代,并开始制作一个模式窗口,以引导人们访问正确的网站。

I can only serve HTML files on the old site, and the structure of the HTML is not very uniform. 我只能在旧站点上提供HTML文件,并且HTML的结构不是很统一。 I decided to add a bit of jQuery to the head of the document, which adds a modal window to the page, giving people links to the new sites. 我决定在文档的开头添加一些jQuery,从而在页面上添加一个模式窗口,使人们可以链接到新站点。

This all works fine on Chrome, Safari and Firefox on Linux and Mac, but when testing on internet explorer on a PC, it looks all wrong, and does not work at all. 这一切在Linux,Linux和Mac上的Chrome,Safari和Firefox上都可以正常运行,但是在PC上的Internet Explorer上进行测试时,它看起来完全错误,并且根本无法正常工作。 I have opened up the console, and get no errors. 我打开了控制台,没有任何错误。

  $(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)
  })

Any ideas as to why this fails appreciated. 关于为什么失败的任何想法都值得赞赏。

Try using this in your CSS and let me know then -- 尝试在CSS中使用它,然后让我知道-

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

This is generally happening with IE when you forget about a little character like comma (,) or semicolon (;) or curly braces ({ }) . 当您忘记诸如逗号(,)或分号(;)或花括号({ })类的小字符时,这通常在IE中发生。 Whatever you have written in above code I have checked this is right, but in some other cases you have to check for all functions. 无论您用上面的代码写过什么,我都检查过这是正确的,但是在其他情况下,您必须检查所有功能。

I have also faced this type of problem and I miss the , in one function. 我也遇到过这类问题,我在一个函数中错过了。 In my opinion lets have a check like this: 在我看来,让我们进行如下检查:

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

I have added a semicolon in last. 我最后加了一个分号。

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

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