我之前发布了关于我遇到的 1 个问题。解决了这个问题,但又带来了另一个问题......
下面的代码...
当在所有其他浏览器中单击"is"时,页面将重新加载,而 SimpleModal 不会恢复。
但在 IE8 中,它会不断加载 SimplModal,从而拒绝访问该网站...
感谢你们提前提供的帮助!
<!-- Init Age Verification Content -->
<div class="age" id="verify">
<div><img src="white.png"></img></div>
<div id="noman">ARE YOU OVER 18?</div>
<div>
<p> If not, leave now and we wont tell your mom.
</br> By continuing you agree you're 18 or older.
</p>
</div>
<div id="YN">
<a href="javascript:window.location.href=window.location.href" id="old">Yes</a>
<a href="example.com" rel="nofollow" id="young">No</a>
</div>
</div>
<!-- If previous page wasn't from us... Verify -->
<script>
if ( document.referrer == null || document.referrer.indexOf(window.location.hostname) < 0 ) {
$("#verify").modal({opacity:85, position: ["20%",""], onOpen: function (dialog) {
dialog.overlay.fadeIn('slow', function () {
dialog.container.slideDown('slow', function () {
dialog.data.fadeIn('slow');
return false;
});
});
}});
}
</script>
最佳答案
如果用户没有通过链接导航到页面,IE 不会设置 document.referrer
From the MDN documentation: "The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark). Since this property returns only a string, it does not give you DOM access to the referring page."
只需将链接的 href 更改为您的页面地址或尝试此解决方法即可。
<a href="javascript:redirect(window.location.href);" id="old">Yes</a>
<script type="text/javascript" >
function redirect(url) {
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
var referLink = document.createElement('a');
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();
} else {
location.href = url;
}
}
</script>
关于javascript - 简单模态不会关闭 | IE8 错误 |窗口位置.href,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20012180/