关闭模态窗口后刷新主页
在给定的网页上,我有一个使用 Thickbox 打开模式窗口的链接。在该窗口中,我有一个用于保存一些数据的表单。提交表单后,我关闭模式窗口。现在我的问题是:关闭模态窗口后可以刷新主页吗?
谢谢。
On a given webpage I have a link that opens a modal window using Thickbox. In that window I have a form which I use to save some data. After I submit the form, I close the modal window. Now my question is: can I refresh the main page after closing the modal window?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在提交表单之后、窗口关闭之前调用此方法:
Call this after the form is submitted and before the window is closed:
假设这是您在模态模式下显示的 div。您必须调用 tb_remove() 来关闭模式窗口。因此,只需在调用之前使用
location.reload();
即可。Suppose this is the div you show in modal mode. You have to call
tb_remove()
to close the modal window. So just uselocation.reload();
before that call.实际上 Thickbox 不再维护,因此最好使用不同的模式窗口。话虽这么说,我知道 Facebox 允许您绑定框打开和关闭事件,如下所示:
Actually Thickbox is no longer being maintained, so it might be better to use a different modal window. That being said, I know Facebox allows you to bind box open and close events like this:
如果使用facebox,只需添加window.location.reload();大约第 148 行,所以你最终会得到类似......
关闭:函数(){
$(document).trigger('close.facebox');
window.location.reload();
返回错误
如果
仍然使用 Thickbox,我确信它同样简单。搜索“close”并添加代码。
If using facebox simply add window.location.reload(); around line 148, so you end up with something like...
close: function() {
$(document).trigger('close.facebox');
window.location.reload();
return false
}
If still using Thickbox I'm sure it's just as easy. Do a search for "close" and add the code.
您可以使用tinybox插件轻松完成此操作:
http://sandbox.scriptiny.com/tinybox2/
关键是将父窗口作为 JS var 传递给函数,然后对该对象调用 location.reload()
You can do this easily with the tinybox plugin:
http://sandbox.scriptiny.com/tinybox2/
The key is to pass in the parent window to the function as a JS var then you call location.reload() on that object