开发者

JQuery page refresh

I am working on a simple chat interface in PHP. This 开发者_运维知识库is my first attempt. I am using iframes for bottom part where chat text is entered and top part where the chat text is displayed.

In the top iframe a set the meta refresh for 5 seconds. So every 5 seconds the page refreshes and displays the new text.

I would like to get rid of the meta refresh and instead refresh the top iframe when the form in the bottom iframe is submitted. So the top iframe is only refreshed when text is actually submitted.

Can I do this with JQuery? Can you suggest a snippet to get me started?

Thank you!


Text enter form's submit button:

$("#submit").click(function(){
    window.parent.reloadMsgs();
});

Main (chat) page:

var reloadMsgs = function(){
    chatFrame = $("#chat_iframe")[0];
    chatFrame.src = chatFrame.src;
};


I believe you would just set a name on your bottom frame:

<iframe name='myFrame'></iframe>

And then in your top frame, your form would target it:

<form method='post' id='myForm' target='myFrame'>
 ...
</form>

This should then send the contents of your form to the bottom frame, which will then reload...


yeah, just set the location.href property of the refreshed iframe. maybe something like document.getElementBy("idOfIframe").location.href="same on, or maybe with random timestemp at the end"

possibly that the property is iframe.contentWindow.bla bla bla

anyway hope this helps. btw, this has nothing to do with jQuery

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜