HTML5按钮如何判断函数是否正确才跳转

html-css09

HTML5按钮如何判断函数是否正确才跳转,第1张

在函数里设置一个flag=false,如果正确则设置flag=true。当点击按钮时,判断flag是否为。true,如果为true,即为函数正确,进行跳转。跳转用window.location.href="http://www.baidu.com"

下次提问最好赋上代码,那样回答起来更精准。

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>无标题文档</title>

</head>

<body>

<h4 onMouseOver="ms(this)" onMouseOut="mo(this)">1111111111111111</h4>

<script>

 function ms(abc)

 {

  abc.style.background="black"  

 }

  function mo(abc)

 {

  abc.style.background="white"  

 }

 

 </script>

</body>

</html>

1.[self performSelector:@selector(函数名) withObject:nil afterDelay:5.0f]

条件:在uiviewController的主线程中

2.[NSTimerscheduledTimerWithTimeInterval:5.0f target:self selector:@selector(函数名) userInfo:nil repeats:NO]

在具体函数中,执行代码,执行完毕以后调用NSTimer invalidate方法来销毁timer

3.[NSThread sleepForTimeInterval:5.0f]

[要延迟执行的方法]

条件:主线程或者子线程都可