【发布时间】:2011-12-27 12:28:27
【问题描述】:
我在我的 URL 中使用了很多哈希来显示消息和内容,但是我遇到了一个问题。点击对话阅读就可以了:
但是,看看当用户在末尾附加另一个哈希时会发生什么:(主题消失了,因为 JavaScript 被混淆了)
(点击图片查看大图)
我怎样才能删除第二个散列如果有一个?我之前在 Gmail 中这样做过,它会自动删除它们。那么,我怎样才能用我的系统做到这一点呢?这是我的哈希码:
if (window.location.hash) {
var messageID = window.location.hash.replace('#!/message/', '');
var msgSubject = $('#subject_' + messageID).text();
//the below code checks if conversation exists
$.get('tools.php?type=id_check&id=' + messageID, function(data) {
if (data == 'true') {
setTimeout(function() {
readMessage(messageID, msgSubject);
}, 200);
}
else {
alertBox('The requested conversation does not exist.', 2500);
window.location = '#';
}
});
}
提前致谢!
【问题讨论】:
标签: javascript jquery hash