如何从服务器端关闭 jQuery (iFrame) 厚盒?
如何从服务器端关闭 jQuery 厚盒 - 我想使厚盒(框架样式)从服务器中的一行关闭 - 当操作完成等时。
我使用厚盒显示文件上传对话框,一旦上传完成后,我想从服务器后面的代码中消除厚盒(就像使用“关闭”或 Esc 键一样)。
另外,当我执行 Reponse.Redirect 时,它会在厚盒中打开,我如何将整个内容重定向到新页面。
How to close jQuery thickbox from server side - I want to cause the thickbox (frame style) to be closed from a line in the server - when an action is done etc.
I use the thickbox to show a file upload dialog, and once the upload is complete, i wanna dismiss the thickbox from the server's code behind (just like it would do with the 'Close' or Esc key).
Also, when I do Reponse.Redirect it opens up in the thickbox, how can i redirect the entire thing to a new page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
凯,你知道吗? 我什至懒得等待对该评论的回应。
这个问题没有神奇的解决方案。 没有代码片段就足够了。 这个问题纯粹是概念性的,您还有一个概念需要学习。
这里的概念是如何使 Javascript 和服务器端编码协同工作以发挥您的优势。 它们是两种截然不同的生物,从服务器端执行客户端任务是行不通的。
解决这个问题有很多不同的方法。 假设(因为您没有提供任何详细信息)一旦在thickbox 中提交了表单,您希望关闭thickbox。 很公平。 我的方法是创建一个
close_this_thickbox()
函数,将其放在我的 .js 文件中,然后,提交表单后,将生成的页面打印。
(对于最终用户来说,更简洁的解决方案可能是通过 AJAX 提交表单,然后将
close_this_thickbox
作为回调,但这对于这里的讨论来说听起来有点太花哨了。)与上述概念类似的方法是获得所需效果的唯一方法。 您必须创建客户端代码,然后让服务器端打印对所述代码的调用。
至于应用于整个窗口的服务器端重定向,同样,如果没有相同的方法就不会发生这种情况。 您必须调用一段脚本来实现您想要的效果,而不是使用内置的服务器端重定向方法,例如
。 不可能有服务器端解决方案。
希望您能够成功应用这个概念,并祝您在 Web 开发之旅中好运。 有什么需要澄清的吗?
Kay, ya know what? I'm not even gonna bother waiting for a response on that comment.
There is no magic solution to this problem. No code snippet will suffice. This question is purely conceptual, and you have a concept left to learn.
The concept here is how to make Javascript and server-side coding work together to your advantage. They are two vastly different creatures, and performing client-side tasks from the server-side WILL NOT WORK.
There are many different approaches to this issue. Let's say that (since you gave no details whatsoever) that once a form is submitted in the thickbox, you wish to close the thickbox. Fair enough. My approach would be to create a
close_this_thickbox()
function, have it lying around in my .js file, then, once the form is submitted, to have the resulting page print<script>close_this_thickbox()</script>
.(The cleaner solution for the end user would likely be to have the form submit via AJAX, then have
close_this_thickbox
as a callback, but that sounds slightly too fancy for this discussion here.)An approach similar in concept to the above is the only way to get the desired effect. You must create client-side code, then have the server side print an invocation of said code.
As for server-side redirection applying to the whole window, again, such can not occur without the same approach. Instead of using your built-in server-side redirect methods, you must invoke a piece of script that results in the effect you want, e.g.
<script>top.location = 'http://example.com'</script>
. No server-side solution is possible.Here's hoping that you can successfully apply this concept, and best of luck in your web development journey. Anything need clarification?
我本来打算发布一个类似的问题,然后发现了这个线程,所以我想我添加到它。 以下是详细信息。
在我的母版页中,我得到了以下触发厚盒的链接
这是我的login.aspx页面的HTML
,我的login.aspx页面背后的代码如下
所以当用户成功验证时我只需隐藏一个div并显示另一个。 另一个包含继续按钮,用于关闭厚盒并重新加载父级。 现在这不是最好的解决方案,但它可以工作,希望有人可以提供一些代码,在成功提交任务后触发厚盒的自动关闭。
I was going to post a similar question then found this thread so I figured I add to it. Here are the details.
in my master page I got the following link which triggers the thickbox
This the HTML for my login.aspx page
and the code behind for my login.aspx page is as follows
So when the user authenticates successfully i simply hide one div and show the other. The other containing the continue button which closes the thickbox and reloads the parent. Now this is not the best solution but it works hopefully someone can provide some code which would trigger the automatic closing of the thickbox upon successful task submission.
如果我正确理解你的问题...
你无法从服务器端与 javascript 交互。 两者是相互独立的。 无论你在服务器上做什么,已经渲染的 JavaScript 都不会改变。 您想“关闭”它以便在页面加载时将其关闭吗? 但如果它已经加载,您在服务器上执行的任何操作都不会将其关闭。
其次,如果您在服务器上使用asp 使用response.redirect,并且它是由javascript 调用的,那么您只需重定向ajax 请求中的内容即可。 您必须从客户端重新加载才能更改当前脚本。
如果我假设不正确,请纠正我。
If I understand what you're asking correctly...
You can't interact with javascript from the server-side. The two are independent of each other. No matter what you do on the server, javascript that is already rendered won't change. Do you want to 'close' it so that when the page loads it is closed? But if it has already loaded, nothing you do on the server will close it.
Secondly, if you're using response.redirect on the server with asp, and it's being called by javascript, you're simply redirecting the content inside the ajax request. You have to reload from the client side to change the current script.
Please correct me if I assumed incorrectly.
这是你需要的吗?
我想我正在做类似的事情。 Checkout 按钮位于粗框中,当单击 checkout 时,它会重定向到 Checkout.aspx
is this what you need?
i think am doing something similar. the Checkout button is in the thickbox, when checkout clicked it redirects to Checkout.aspx