从弹出窗口登录网站后如何重定向到主窗口
我有一个 ASP.NET 网站 StartPage,无需登录即可查看。 在此起始页上,有一个登录链接按钮,单击该按钮将打开一个小的登录弹出页面。不幸的是,在用户输入他们的腰部凭据并单击登录后,目标页面会在同一弹出窗口中加载,这不是我想要的结果。
我想要的是,当用户成功通过身份验证时,弹出的登录窗口应该关闭并将用户重定向到目标页面,但该目标页面应该加载到原始主窗口中。
这是打开弹出窗口的函数
function PopupCenter(pageURL, title, w, h) {
var left = (screen.width / 2) - (w / 2);
var top = (screen.height / 2) - (h / 2);
var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}
,linkbutton OnClient 属性如下
<asp:LinkButton ID="LinkButton2" runat="server"
onclientclick="PopupCenter('Login.aspx', 'myPop1',400,300);">Log Me In</asp:LinkButton>
I have an asp.net website StartPage that does not require signing-in, in order to view it.
On this StartPage, there is a Login linkbutton that when clicked opens a small Login popup page. Unfortunately, after the user has entered their loin credentials and clicks login, the destination page loads in the same popup window which is not my desired result.
What i would like is when the user has successfully been authenticated, the popup Login window should close and redirect the user to the destination page, but this destination page should load in the original main window.
This is the function that opens the popup windows
function PopupCenter(pageURL, title, w, h) {
var left = (screen.width / 2) - (w / 2);
var top = (screen.height / 2) - (h / 2);
var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}
And the linkbutton OnClient property is like so
<asp:LinkButton ID="LinkButton2" runat="server"
onclientclick="PopupCenter('Login.aspx', 'myPop1',400,300);">Log Me In</asp:LinkButton>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这种方法是不可能的,我的意思是你应该避免使用window.open。相反,您可以创建自定义弹出窗口(例如使用 div)。在此弹出窗口中,您需要创建与“Login.aspx”页面中相同的 HTML 元素以及相同的服务器逻辑。您需要修改 PopupCenter 函数来打开自定义弹出窗口,而不是使用 window.open。
This is impossible with this approach, I mean you should avoid using window.open. Instead you can create your custom pop-up (for example using divs). On this pop-up you will need to create same HTML elements as in your "Login.aspx" page and the same sever logic too. Than you will need to modify your PopupCenter function to open your custom pop-up instead of using window.open.