onClick在5秒后重定向到一侧
onClick redirect to a side after 5 sec
我该如何添加到按钮中,以便在我按下按钮后,它会在大约5秒后将我重定向到一侧?我尝试了很多不同的东西,但对我不起作用。。。它需要是一个onClick函数(javascript)。
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:
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寻求帮助!
这应该会将您重定向到另一个站点:
window.location="http://www.yoururl.com";
您基本上可以创建一个setInterval(代码,毫秒)为5000的函数。并将该代码替换为u所具有的函数。
<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>
看起来您正在使用jQuery。你可以这样做:
$('#id-of-button').click(function() {
setTimeout(function () { location.href='http://url.tld'; }, 5000);
$(this).unbind();
});
演示
购买前试用
相关文章:
- 通过javascript重定向html传递php变量
- JavaScript下拉菜单-点击按钮并根据所选值重定向到url
- 使用angular重定向到html页面
- 如何在chrome扩展中重定向到html页面
- 无法从jquery Mobile导航栏重定向到另一个页面
- 在 n 秒内重定向并传递值
- 页面加载上的加载模式&5秒后重定向
- javascript:检查鼠标是否按下并从零开始计数,x秒后重定向
- onClick在5秒后重定向到一侧
- angular$timeout在3秒后重定向
- yii-如何在10秒后重定向
- 使用 JavaScript 等待 X 秒后进行页面重定向
- MVC在暂停四秒后重定向到另一个页面
- Angularjs的ng-click在秒点击时重定向
- 在1秒内重定向setinterval或停止setinterval的条件
- 如果没有操作,15秒后重定向页面
- 5秒后重定向,但只允许引荐来源网址访问该页面
- 在n秒后不断重定向
- 在空闲/不活动60秒后重定向用户
- 如何每10秒重定向一个页面