菜鸟问题:怎么让网页自动隔一秒刷新,并且执行相应的动作???
下面是当点击一个按钮的时候让左边的textarea自动到右边的textarea
点击另外一个时候执行相反的动作
<form action= "editpage.jsp " method= "post " name= "form1 ">
<textarea rows= "15 " cols= "33 " name= "textedit " wrap= "hard "> </textarea>
<input type= "button " name= "button " value= "从左到右 " title= "submit " onclick= "mk_confirm() ">
<input type= "button " name= "button1 " value= "从右到左 " title= "submit " onclick= "mk_confirm1() ">
<textarea rows= "15 " cols= "33 " wrap= "hard " name= "textedit2 "> </textarea>
</form>
<script>
function mk_confirm()
{
var textedit = document.getElementById( "textedit ").value;
var textedit2= document.getElementById( "textedit2 ");
textedit2.value = textedit;
}
function mk_confirm1()
{
var textedit2 = document.getElementById( "textedit2 ").value;
var textedit= document.getElementById( "textedit ");
textedit.value = textedit2;
}
</script>
现在怎么让网页自动执行这个动作,也就是不需要自己去点那个按钮,默认刷新是一秒吧,例如,一秒就让左边的内容代替右边的内容。
------解决方案--------------------试一下这个
<form action= "editpage.jsp " method= "post " name= "form1 ">
<textarea rows= "15 " cols= "33 " name= "textedit " wrap= "hard "> </textarea>
<input type= "button " name= "button " value= "从左到右 " title= "submit " onclick= "mk_confirm() ">
<input type= "button " name= "button1 " value= "从右到左 " title= "submit " onclick= "mk_confirm1() ">
<textarea rows= "15 " cols= "33 " wrap= "hard " name= "textedit2 "> </textarea>
</form>
<script>
function mk_confirm()
{
var textedit = document.getElementById( "textedit ").value;
var textedit2= document.getElementById( "textedit2 ");
textedit2.value = textedit;
}
function mk_confirm1()
{
var textedit2 = document.getElementById( "textedit2 ").value;
var textedit= document.getElementById( "textedit ");
textedit.value = textedit2;
}
//加了这个
setInterval( "mk_confirm() ",1000);
</script>