2

我有一个弹出窗口,其中包含一个为报告收集数据的表单。当我在该窗口中单击提交时,我希望它关闭弹出窗口,并在调用弹出窗口的原始窗口中打开报告。

我想我可以通过使用在正确的窗口中打开报告

{ :target => <name of window> }

form_tag,但我不知道如何确定或设置原始窗口的名称。

我也不知道如何关闭弹出窗口。

4

4 回答 4

2

:target => adds the html attribute target to the link. This opens up a new window and names the new window the target.

You have to use javascript or Ajax to redirect the old page,

window.opener.location.href="http://new_url";

and then close the old window.

window.close();

This can be done either through the rjs file or directly in the javascript.

于 2008-10-01T21:21:03.963 回答
0

对初学者来说如何?

# The submit button in your child window's view:
<%= button_to_function 'Save', "$('my_form').submit(); window.opener.location.reload(); window.close();" %> 
于 2008-08-30T15:55:54.737 回答
0

可以使用 onClick html 事件关闭弹出窗口,如下所示:

<%= submit_tag "Go!", {:onClick => "window.close()"} %>
于 2008-08-30T16:49:52.173 回答
0

尝试这个:

function fclosepopup(){
window.opener.location.replace="URL";
window.close();
}

它将关闭当前窗口并将您带到父窗口中的下一页。

于 2009-01-15T06:56:56.903 回答