很抱歉这可能是个愚蠢的问题,但我怎样才能在if
语句中使用逗号?
这是正常的部分:
$("a[rel*=overlay]").overlay({
fixed: false,
closeOnClick: false,
onBeforeLoad: function() {
var wrap = this.getOverlay().find("#contentWrap");
var eID = this.getTrigger().attr("id").replace(/.$/g, '');
var hiURL = document.location.href;
var eURL = this.getTrigger().attr("href");
var stateObj = { foo: "bar" };
wrap.load(this.getTrigger().attr("href"));
window.location.hash = (eID);
},
onClose: function() {
window.something(something);
}
});
我需要:
$("a[rel*=overlay]").overlay({
fixed: false,
closeOnClick: false,
onBeforeLoad: function() {
var wrap = this.getOverlay().find("#contentWrap");
var eID = this.getTrigger().attr("id").replace(/.$/g, '');
var hiURL = document.location.href;
var eURL = this.getTrigger().attr("href");
var stateObj = { foo: "bar" };
wrap.load(this.getTrigger().attr("href"));
if (Modernizr.history) {
window.history.replaceState(currentPage, document.title, eURL);
},
onClose: function() {
window.history.replaceState(currentPage, document.title, "dort");
} else {
window.location.hash = (eID);
}
}
});
但是"},"
在Dreamweaver中显示错误。
答案 0 :(得分:1)
你接近正确的地方,只缺少一个支架......
$("a[rel*=overlay]").overlay({
fixed: false,
closeOnClick: false,
onBeforeLoad: function() {
var wrap = this.getOverlay().find("#contentWrap");
var eID = this.getTrigger().attr("id").replace(/.$/g, '');
var hiURL = document.location.href;
var eURL = this.getTrigger().attr("href");
var stateObj = { foo: "bar" };
wrap.load(this.getTrigger().attr("href"));
if (Modernizr.history) {
window.history.replaceState(currentPage, document.title, eURL);
} // <-- Missing this one
},
onClose: function() {
window.history.replaceState(currentPage, document.title, "dort");
} else {
window.location.hash = (eID);
}
}
});