简体   繁体   English

Modal无法在IE9中运行 - 在打开开发人员工具时,它可以正常工作

[英]Modal not working in IE9 - on opening developer tools it then works fine

I've been trying to get a modal working and it seems fine on all tested browsers, except for one problem on IE9. 我一直试图让一个模态工作,它似乎在所有测试的浏览器上,除了IE9上的一个问题。 On page load, the modal does not work. 在页面加载时,模态不起作用。 If I then open the dev tools and close them again (or even just keep them open), it works fine. 如果我再打开开发工具并再次关闭它们(甚至只是让它们保持打开状态),它就能正常工作。 How can I even debug this issue? 我怎么能调试这个问题呢?

Edit: Here's the link: http://dev.birddartmouth.co.uk 编辑:这是链接: http//dev.birddartmouth.co.uk

Here's my code. 这是我的代码。

HTML: HTML:

<a href="#" class="item" data-reveal-id="292">
    <img src="http://dev.birddartmouth.co.uk/wp-content/uploads/2013/10/096.jpg" />
</a>

<div id="292" class="reveal-modal">
    <a href="#" class="close-reveal-modal"><i class="close icon close-reveal-modal"></i></a>
    <div class="header">
    Bow tie neck silk overlay top/dress with sequin hem &#8211; cream, grey                                         <p>&#163;0</p>
    </div>
    <div class="content">
        <img src="http://dev.birddartmouth.co.uk/wp-content/uploads/2013/10/096.jpg" />
    </div>
</div>

JS: JS:

$( "a.item" ).click(function( event ) {
  event.preventDefault();
    var elementClicked = "#" + $(this).attr("data-reveal-id");
    console.log(elementClicked);
    $(elementClicked).foundation('reveal', 'open');
});

$( "a.close-reveal-modal" ).click(function( event ) {
  event.preventDefault();
    var openElementClicked = "#" + $(this).parent().attr("id");
    console.log(openElementClicked);
    $(openElementClicked).foundation('reveal', 'close');
});

console.log throws errors when the console is not open in IE. 当控制台未在IE中打开时,console.log会引发错误。

Comment out the console lines or check for support 注释掉控制台线或检查支持

window.console && console.log(elementClicked);

I know this is an old thread, but thought I'd pass on this solution anyway. 我知道这是一个老线程,但我认为无论如何我都会传递这个解决方案。

To avoid the issue with IE, as @epascarello mentioned, we use a function called ltc (log to console) which is sitting in our global.js library. 为了避免IE的问题,正如@epascarello所提到的,我们使用一个名为ltc (log to console)的函数,它位于我们的global.js库中。

function ltc(what) {
  try {
    console.log(what); 
  } catch(e) {
    return;
  }
}

Now instead of using console.log("my message") , it's simply ltc("my message") ; 现在,而不是使用console.log("my message") ,它只是ltc("my message") ;

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

相关问题 在IE浏览器中,只有打开开发人员工具后,React.Js JavaScript代码才能正常工作 - In IE browser, React.Js JavaScript code works fine only after opening developer tools jQuery 1.10.2和ie9 - 仅在打开开发人员工具时才有效 - jQuery 1.10.2 and ie9 - works only if developer tools is opened IE Developer Tools断点不起作用 - IE Developer Tools breakpoints are not working IE9在使用开发人员工具时是否启用“某些东西”? - Does IE9 enable 'something' when using developer tools? console.log在ie9中使用警报,并打开开发人员工具 - console.log uses alerts in ie9 with developer tools open jQuery在chrome中工作正常,在IE9 / IE8等环境中失败 - jQuery works fine in chrome fails in IE9/IE8 etc 右键单击和IE F12开发人员工具不适用于模式窗口 - Right-click and IE F12 Developer Tools aren't working on modal window Request.UrlReferrer在IE8中无法正常工作,在IE9中也可以正常工作 - Request.UrlReferrer is not working in IE8 and working fine IE9 我可以在IE8-9中检测用户打开开发人员工具吗? - Can I detect the user opening developer tools in IE8-9? Javascript 仅在 chrome 中打开开发人员工具后才有效 - Javascript only works after opening developer tools in chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM