我想用JavaScript延期一段500的链接 [英] I want to delay a link for a period of 500 with javascript

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

问题描述

我一直在研究Stackoverflow问题,试图通过简单的链接延迟获得帮助;我想把它放在一个div上,而且我不能对我找到的例子做正面或反面。



到目前为止,我明白我需要暂停href的本地功能,但我不知道如何做到这一点。代码对我来说依然非常陌生。帮助?

解决方案

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

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


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.

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?

解决方案

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天全站免登陆