从弹出窗口登录网站后如何重定向到主窗口

发布于 2024-09-19 02:07:40 字数 866 浏览 2 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在风中等你 2024-09-26 02:07:40

这种方法是不可能的,我的意思是你应该避免使用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文