简体   繁体   English

Internet Explorer 7 弹出模式未打开

[英]Internet Explorer 7 popup modal not opening

On Firefox and Chrome it's working fine, plus on latest IE it also works, but on IE7 and IE8 popup doesn't open.在 Firefox 和 Chrome 上运行良好,在最新的 IE 上也可以运行,但在 IE7 和 IE8 上无法打开弹出窗口。

http://webteezy.com/demos/prototype.html#

What I am trying to do, when clicked on balloon there is popup opens with small amount of data in it.我正在尝试做的是,当单击气球时,会打开弹出窗口,其中包含少量数据。 But when clicked on MetaData in that popup another popup modal should open.但是,当单击该弹出窗口中的 MetaData 时,应打开另一个弹出模式。 It works fine in other browsers, except for IE7 and IE8.它在除 IE7 和 IE8 之外的其他浏览器中运行良好。

What can I try?我可以尝试什么?

eg例如

MetaData button showing in Modal when balloon is pressed按下气球时以模态显示的元数据按钮

<p><a href=# class="butt CB00071">Data</a><a href="#CB00071" class="butt hover CB00071">MetaData</a></p>

script goes below脚本如下

    $('body').on('click','.CB00071',function(e){
    $('#CB00071').css({'display':'inline-block',
        '*display': 'inline',
        'zoom': '1'});
});

and finally the Modal To Show up when button is pressed.最后是按下按钮时显示的模态。 Below is the Modal.下面是模态。

<div id="CB00071" class="overlay light" style="display: none">
    <a class="cancel" href="#"></a>
    <div class="popup">
        <h2>KINGDOM OF SAUDI ARABIA</h2>
        <h3>GENERAL COMMISSION FOR SURVEY, GEODESY & LAND SURVEY</h3>
        <div class="content">

            <div class="col-1-1">
                <div class="col-1-2"><p class="info">Site Name <span>CB0007</span></p></div>
                <div class="col-1-4"><p class="info">Station Number <span>CB00071</span></p></div>
                <div class="col-1-4"><p class="info">Site Type <span>Ex-Center</span></p></div>
            </div>
            <div class="col-1-2"><p class="info">Province <span>Mekkah</span></p></div>
            <div class="col-1-2"><p class="info">Town/Location Name <span>CB0010</span></p></div>
            <div class="col-1-1">
                <div class="col-1-4"><p class="info">Latitude <span>N21°37'02.54104"</span></p></div>
                <div class="col-1-4"><p class="info">Longitude <span>E40°08'48.54207"</span></p></div>
                <div class="col-1-4"><p class="info">Height <span>614.224m</span></p></div>
                <div class="col-1-4"><p class="info">Absolute Gravity<span>978540849.6(µGal)</span></p></div>
            </div>
            <p><a href="logsheets/obs_card_cb071.pdf" class="butt hover">Download Details Log Sheet</a></p>
        </div>
    </div>
</div>

Why is it not working on IE7/8?为什么它不能在 IE7/8 上运行?

You are trying to reveal the popup layer using the CSS3 pseudo selector :target您正在尝试使用 CSS3 伪选择器显示弹出层:target

Your css:你的CSS:

.overlay:target {
  visibility: visible;
  opacity: 1;
}

This is (basically) how it works:这是(基本上)它是如何工作的:

  • Your overlay divs each have an id attribute eg <div id="CB00070" class="overlay light">...</div>您的叠加divs每个都有一个 id 属性,例如<div id="CB00070" class="overlay light">...</div>

  • When a link with an href that refers to that id ( <a href="#CB00070">...</a> ) is clicked, that div becomes the target of the click.当单击带有引用该 id ( <a href="#CB00070">...</a> ) 的 href 的链接时,该 div 将成为单击的目标。

  • The target div will inherit any :target styling that has been specified for it, in this case visibility:visible; opacity:1;目标div将继承为其指定的任何:target样式,在本例中为visibility:visible; opacity:1; visibility:visible; opacity:1;

Unfortunately IE versions less than 9 do not behave in this way as the :target selector was introduced in a later version of CSS ( http://caniuse.com/#feat=css-sel3 )不幸的是,低于 9 的 IE 版本不会以这种方式运行,因为:target选择器是在更高版本的 CSS ( http://caniuse.com/#feat=css-sel3 ) 中引入的

If you really do need to support older IE versions you could try revealing the relevant <div> by adding a class that will reveal it and removing the class to hide it again, something like:如果您确实需要支持较旧的 IE 版本,您可以尝试通过添加一个将显示它的类并删除该类以再次隐藏它来显示相关的<div> ,例如:

$('body').on('click','.CB00070',function(e){
    // reference our target div
    var targetDiv=$('#CB00070');
    // add a class so that it can be styled using css which older browsers will recognise
    targetDiv.addClass('target');
    // make sure there is only ever one active target
    targetDiv.siblings('.target').removeClass('target'); 
    // add in the behaviour that was working previously 
    // (though these styles could be put into the stylesheet)
    targetDiv.css({'display':'inline-block',
        '*display': 'inline',
        'zoom': '1'});
});

You will also need to remove the class when the cancel link is clicked单击取消链接时,您还需要删除该类

$('body').on('click','.cancel', function(e){
    $('div.target').removeClass('target');
})

Then you will need to reference the target class in your css, using .target instead of :target然后你需要在你的 CSS 中引用目标类,使用.target而不是:target

You might also want to look into some way of not having to list each of those meta-data links:您可能还想研究一些不必列出每个元数据链接的方法:

$('body').on('click','a[href ^= "#CB"]',function(e){
// this should catch all of your meta data links
// you will need to find the target div using the href 
// attribute of the link that has just been clicked
}) 

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

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