[英]onClick redirect to a side after 5 sec
How do i add to a button so after i press it. 我如何添加到按钮,所以按下按钮后。 it will redirect me to a side after like 5 sec?
它会在5秒后将我重定向到一侧吗? I have tried so much different stuff but it is not working for me... It need to be a onClick function (javascript).
我尝试了很多不同的东西,但对我来说不起作用...它必须是onClick函数(javascript)。
HTML: HTML:
<html>
<head>
<style type="text/css">
#save_first { display: none; }
#save_second { display: none; }
#save_third { display: none; }
</style>
<script type="text/javascript" src="http://mctheblitz.com/servers/js/jquery.js"></script>
<script type="text/javascript" src="js/custom.js"></script>
</head>
<body>
<input type="button" value="Save" onClick="save();"/>
<div id="save_first"></div><div id="save_second"></div>
<?php
</body>
</html>
Javascipt: Javascipt:
function save() {
$('#save_first').html('Validating...');
$('#save_first').fadeIn(1);
$('#save_first').delay(2000);
$('#save_first').fadeOut(300);
$('#save_second').html('Successfully log in!');
$('#save_second').hide();
$('#save_second').delay(2350);
$('#save_second').fadeIn(0);
}
Tnx for help! Tnx寻求帮助!
This should redirect you to another site: 这应该将您重定向到另一个站点:
window.location = " http://www.yoururl.com "; window.location =“ http://www.yoururl.com ”;
You can basicly just create a function with setInterval(code,millisec) to 5000. and replace the code with a function u have. 您基本上可以只创建一个setInterval(code,millisec)为5000的函数,然后将代码替换为您拥有的函数。
<html>
<body>
<input type="text" id="clock">
<script language=javascript>
function fiveseconds() {
setInterval(function(){clock()},5000);
}
function clock() {
alert("pow");
}
</script>
<button onclick="fiveseconds()">Stop</button>
</body>
</html>
It looks like you're using jQuery. 看起来您正在使用jQuery。 You can do it like this:
您可以这样做:
$('#id-of-button').click(function() {
setTimeout(function () { location.href='http://url.tld'; }, 5000);
$(this).unbind();
});
Demo 演示版
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.