[英]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 – cream, grey <p>£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.