我想使用 javascript 将链接延迟 500 年 [英] I want to delay a link for a period of 500 with javascript

查看:21
本文介绍了我想使用 javascript 将链接延迟 500 年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在查看 Stackoverflow 的问题,试图获得有关简单链接延迟的帮助;我想把它放在一个 div 周围,但我无法对我找到的例子做出正面或反面.

I've been looking through the Stackoverflow questions, trying to get help with a simple link delay; I want to put it around a div, and I can't make heads or tails of the examples I've found.

到目前为止,我知道我需要停止href的本机功能,但我不知道该怎么做.代码对我来说仍然很陌生.有帮助吗?

So far, I understand that I need to halt the native function of href, but I don't know how to do that. The code is still very alien to me. Help?

推荐答案

将您的 href 属性设置为 href="javascript:delay('URL')" 和 JavaScript:

Set your href attribute as href="javascript:delay('URL')" and JavaScript:

function delay (URL) {
    setTimeout( function() { window.location = URL }, 500 );
}

这篇关于我想使用 javascript 将链接延迟 500 年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆