href我在所有页面上都有一个链接,每次用户单击它时,我都想延迟从带有<a>标签的下一页加载。我试图<a>在 HTML 中的标记中获取链接,然后尝试延迟它,但超时不起作用。任何人都可以帮忙吗?
var link = document.querySelector('a').getAttribute('href')
setTimeout(function() {
location.href = link
}, 4000);
href我在所有页面上都有一个链接,每次用户单击它时,我都想延迟从带有<a>标签的下一页加载。我试图<a>在 HTML 中的标记中获取链接,然后尝试延迟它,但超时不起作用。任何人都可以帮忙吗?
var link = document.querySelector('a').getAttribute('href')
setTimeout(function() {
location.href = link
}, 4000);
我相信这会帮助你:
const a = document.querySelector('a');
a.addEventListener("click", (e) => {
e.preventDefault();
const link = e.target.href;
setTimeout(() => {
window.open(link)
}, 1000)
})
if ( document.getElementById('primaryCTA') != null) {
var primaryCTA = document.getElementById("primaryCTA").onclick = showSpinner;
function showSpinner() {
var spin = document.getElementById("tick-animation-small");
if(spin.style.display == 'inline-flex')
spin.style.display = 'none';
else
spin.style.display = 'inline-flex';
var saving = document.getElementById("mini-spinner-copy");
if(saving.innerHTML == "Continue" )
saving.innerHTML = "Saving progress";
else
saving.innerHTML == "Continue";
var element = document.getElementById("mini-spinner-copy");
element.classList.add("fadeIn");
const a = document.querySelector('a');
a.addEventListener("click", (e) => {
e.preventDefault();
const link = e.target.href;
setTimeout(() => {
window.open(link)
}, 3000)
})
};
}