变量传递
源页面
function navigateToIndex() {
const targetUrl = `index.html?param=${param}`;
window.location.href = targetUrl;
}
<div id="index0" class="index0" onclick="navigateToIndex()">
<a href="#">return Avatar</a>
</div>
目标页面
function getQueryParam(paramName) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
return urlParams.get(paramName);
}
document.addEventListener('DOMContentLoaded', function() {
const paramValue = getQueryParam('param');
alert(paramValue);