【发布时间】:2014-01-30 09:12:53
【问题描述】:
我正在开发的网站上的脚本有问题。它在 Safari、Opera 和 Chrome 中运行良好,但在 Firefox 中无法运行。
当您单击链接时,我尝试将 div #contain 从内部链接加载到覆盖 div,然后将其隐藏。所有这些在我上面提到的浏览器中都可以正常工作,但在 Firefox 中无法正常工作,点击功能只是像往常一样打开链接(重新加载页面)。
任何想法为什么它在 Firefox 中不起作用?有什么我遗漏的吗?
$(document).ready(function(){
var $ov = $('.overlay'),
$tp = $('#transparent'),
URL = ' ',
siteURL = "http://" + top.location.host.toString(),
$internal = $("a[href^='"+siteURL+"'], a[href^='/'], a[href^='./'], a[href^='../'], a[href^='#']:not('.no')"),
hash = window.location.hash,
$el, $allLinks = $("a");
$tp.hide();
$ov.hide();
$tp.click(function(){
$ov.empty();
$tp.hide();
$ov.hide();
});
if (hash) {
$ov.show();
$tp.show();
hash = hash.substring(1);
URL = hash + " #contain";
$ov.load(URL);
};
$internal.each(function(){
$(this).attr("href", "#" + this.pathname);
}).click(function(){
$tp.show();
$ov.show();
$el = $(this);
URL = $el.attr("href").substring(1);
URL = URL + " #contain",
$ov.load(URL);
});
});
【问题讨论】:
-
我的一个部分视图有完全相同的问题。尝试在 $ov.load(URL); 之前添加警报;看看这是否有效。它对我有用。我仍在寻找它为什么这样做和/或如何解决它。
标签: javascript jquery firefox