添加url参数跳转
Vercel Deploy / deploy (push) Successful in 1m15s

This commit is contained in:
2026-04-26 10:33:54 +08:00
Unverified
parent c54e5209af
commit efec4bf735
2 changed files with 36 additions and 0 deletions
+18
View File
@@ -202,10 +202,28 @@
window.location.href = `certificate.html?id=${id}`; window.location.href = `certificate.html?id=${id}`;
} }
function initializeSearchTermFromUrl() {
const params = new URLSearchParams(window.location.search);
const presetTerm =
params.get('searchTerm') ||
params.get('term') ||
params.get('keyword') ||
params.get('cert_number') ||
params.get('certNumber') ||
params.get('number') ||
params.get('q') ||
'';
if (presetTerm) {
document.getElementById('searchTerm').value = presetTerm;
}
}
document.getElementById('searchBtn').addEventListener('click', handleSearch); document.getElementById('searchBtn').addEventListener('click', handleSearch);
document.getElementById('searchTerm').addEventListener('keypress', e => { document.getElementById('searchTerm').addEventListener('keypress', e => {
if (e.key === 'Enter') handleSearch(); if (e.key === 'Enter') handleSearch();
}); });
initializeSearchTermFromUrl();
</script> </script>
<script src="https://cdn.jsdmirror.cn/gh/bishshi/wechat-detect@main/wechat-detect.js"></script> <script src="https://cdn.jsdmirror.cn/gh/bishshi/wechat-detect@main/wechat-detect.js"></script>
</body> </body>
+18
View File
@@ -203,7 +203,25 @@
resultsDiv.innerHTML = html; resultsDiv.innerHTML = html;
} }
function initializeSearchTermFromUrl() {
const params = new URLSearchParams(window.location.search);
const presetTerm =
params.get('searchTerm') ||
params.get('term') ||
params.get('keyword') ||
params.get('ticket_number') ||
params.get('ticketNumber') ||
params.get('number') ||
params.get('q') ||
'';
if (presetTerm) {
document.getElementById('searchTerm').value = presetTerm;
}
}
document.getElementById('searchBtn').addEventListener('click', handleSearch); document.getElementById('searchBtn').addEventListener('click', handleSearch);
initializeSearchTermFromUrl();
</script> </script>
</body> </body>
</html> </html>