我正在为我开发的网站使用 jQuery 模板,它们在 Chrome、Safari 甚至 IE9 上运行良好,但模板无法在 Firefox 上呈现。我在外部加载它们,并且 $.get 被处理(我已经检查了 Firebug,get 通过并提取了正确的文件),但是随后我看到了一个空白页面并检查了 html 显示了 body 元素仅包含页脚(包含在 html 中),但显示:无,这是它应该的样子,所以 javascript 运行完成(因为页脚隐藏在 loadtemplate 函数中)。Firefox 似乎只是跳过了 $.tmpl() 调用。这是功能:
var loadTemplate = function(templateName){
$.get(templateName, function(template){
$.tmpl(template).appendTo("body");
});
};
var loadHomePage = function(){
history = [];
clearPage();
loadTemplate("./templates/home.tmpl");
current_page = "./templates/home.tmpl";
}
var clearPage = function(){
$(".page-content").remove();
$(".page-header").remove();
$("#popup-container").remove();
$(".page-footer").hide();
};
任何帮助将不胜感激,如果需要,我也可以跟进更多代码。
编辑:即使在 Opera 上工作,我也不需要支持它,所以样式不起作用(使用 Opera 不支持的 LESS 和严格用于 IE 的 css 文件),但它仍然可以毫无问题地加载模板。