开发者

how to auto submit a frame using javascript

HI I have two frames, frame1 has few input text box and a submit . on submit, frame2 shoudl display contents. it is working on manual text enter and submit. i am trying to make a auto submit . (i want the contents of a file to be continuously displayed in frame2 like unix tail cmd )

i wrote a function like

function refreshMe() {
setTimeout('refreshMe()', 5000);
var frm = document.getElementById("_form_");
frm.method="post"
 frm.action = "x开发者_StackOverflowyz.pl";
 frm.target="frame2"
 frm.submit() 
}

it is not working properly. any idea ?

Edit: I found out after commenting few code, 1) that the timer part is working fine. but browser hangs only if I submit form 2) and document.forms["form"].submit() is not working properly(it submits but with NULL values of all elements)

SO i tried using document.forms["form"].Submit.click() it works but browser hangs after few (say 10 ) times of auto submit

Any idea please


I've just cleaned up your code a little bit. It may help fix the problem you are experiencing.

function frameRefresh()
{
    var frm = document.getElementById("_form_");
    frm.method = "post";
    frm.action = "xyz.pl";
    frm.target = "frame2";
    frm.submit();
}

var intervalId = setInterval(frameRefresh,5000);

Using setInterval() allows you to clearInterval(intervalId) at a later stage if you need to stop it from running.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜