Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/js/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ $(function () {

// 初始化处理,在新标签中打开页面
linkOnBlackPage && $("#content a").filter(function () {
let isLinkToCurrentPage = $(this).attr("href").startsWith("#");
let titleId = $(this).attr("href");
let isLinkToCurrentPage = titleId && titleId.startsWith("#");
// 给每个链接到当前页面的链接一个点击事件,通过动画滚动到目标位置
isLinkToCurrentPage && $(this).on('click', function (event) {
let titleId = $(this).attr("href");
Expand Down Expand Up @@ -409,4 +410,4 @@ $(function () {
readProgress();
// 9、为文章中每一个标题都添加一个点击事件,方便锚点分享
addAnchorPoint("article");
});
});