一个小问题,帮忙看下
- JScript code
<html><head><script language="javascript" >function checkSubmit(){ if ($('username').value=="maoge"&&$("password").value=="baqi"){ return true; }else{ return false; $("username").value=""; $("password").value=""; }}function $(id){ return document.getElementById(id);}</script></head><body><form action="demo7_1.html" >用户名<input type="text" id="username"/><br/>密  码<input type="text" id="password"/><br/>      <input type="submit" value="登陆" onclick="return checkSubmit();"/></body></html><html><head><title>good web</title><script language="javascript">function Jump(){ clearInterval("mytime"); window.open("http://www.baidu.com/index.php?tn=sogouie_dg");}setTimeout("tiao()",5000);function changeSec(){ $("myspan").innerText=parseInt($("myspan").innerText)-1;}var mytime=setInterval("changeSec()",1000);function $(id){ return document.getElementById(id);}</script></head><body><span id="myspan">5</span></body></html><html><head></head><body>good luck</body></html>为什么最后读秒完了不能挑战过去?
[解决办法]
你JS没报错 ? $("#username").val() 才可以获取值吧
[解决办法]
几个问题:
setTimeout("tiao()",5000);//有这个函数tiao的定义?
function changeSec(){
$("myspan").innerText=parseInt($("myspan").innerText)-1;
}
没看到这儿当倒计时到达0时有调用Jump方法,这怎么会自己跳转呢?
不用说,估计是copy的代码,这样改:
function Jump(){
clearInterval("mytime");
window.open("http://www.baidu.com/index.php?tn=sogouie_dg");
}
function changeSec(){
$("myspan").innerText=parseInt($("myspan").innerText)-1;
if(parseInt($("myspan").innerText)<=0)
Jump();
}
var mytime=setInterval("changeSec()",1000);
function $(id){
return document.getElementById(id);
}