Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
页面浏览次数
  • Loading branch information
xiangmingya authored Jun 26, 2024
1 parent c1a4efc commit 32cbf61
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,20 @@ document.addEventListener('DOMContentLoaded', () => {
fetchExchangeRates();
updateExchangeRate();
});

//页面浏览次数
window.onload = function() {
fetch('/record-view', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
document.getElementById('viewCount').textContent = data.views;
})
.catch(error => {
console.error('Failed to record view:', error);
});
}

0 comments on commit 32cbf61

Please sign in to comment.