Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9235457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:02:25+00:00 2026-06-18T07:02:25+00:00

I’m working in MVC and I want to be able to implement a login

  • 0

I’m working in MVC and I want to be able to implement a login system using a popup window.

The part I am stuck on is, when a successful login occurs in the popup window – it then needs to close and a redirect has to happen on the main page. I am struggling to achieve this as I am running into a whole load of scope issues with JQuery.

I create my popup window with this:

window.open('@Url.Action("Login", "User", null, "http")', 'Login', 'height=500,width=300');

It would be nice to be able to prepend var window = to the above code so that I was able to refrence the window I want to close on successful login – but that variable is out of scope from my Login window:

@{
  ViewBag.Title = "Login";
}

<h2>Login</h2>

<p id="login-fail" style="display:none">Incorrect username/password</p>

@using (Html.BeginForm()) {
  @Html.LabelFor(x => x.Email, new { id = "txt-email" })
  @Html.TextBoxFor(x => x.Email)
  <br />
  <label for="txt-password">Password</label>
  <input id="txt-password" type="password" />
  <input type="submit" value="Login" />
}


<script type="text/javascript">
  $(function () {
    var success = '@Model.Success';
    if (success == "True") {
      loginSuccess(this.window);
    }
    var failed = '@Model.Failed';
    if (failed == "True") {
      $("#login-fail").show();
    }
  });
</script>

I refresh the partial view when the form is posted and Jquery checks for success when the page is loaded. On success, I then try to pass the current window to a js function called loginSuccess:

function loginSuccess(elem) { // successful login has occurred
  elem.close();
  window.location = //getRedirect;
}

So far I cannot get the popup window to close, and then I need to focus to my main window when I set my redirect.

I have a javascript file called functions that both my main window and popup each reference. However, the js that creates the popup window is not in the functions file and the window variable is not available to either window.

Long story short, I am attempting to mock the LinkedIn login process, so the code that creates the popup window is invoked by calling IN.UI.Authorize().place(); – which rules out returning the window variable as the code has to remain the same whether I use my mock LinkedIn or the real one.

Would really appreciate any help with this, particularly referencing the popup window somehow and then refocusing to the main window for the redirect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:02:27+00:00Added an answer on June 18, 2026 at 7:02 am

    I found that referencing myfunctions js file from both pages was causing problems as the main page’s js file might be able to reference the child page, but this would be null according to the child page’s js file, etc.

    window.opener helped solve the problem for me, by calling the function attached to the parent window:

    <script type="text/javascript">
      $(function () {
        var success = '@Model.Success';
        if (success == "True") {
          window.opener.loginSuccess(window);
        }
        var failed = '@Model.Failed';
        if (failed == "True") {
          $("#login-fail").show();
        }
      });
    </script>
    

    The popup now closes and redirect occurs on main page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am using JSon response to parse title,date content and thumbnail images and place
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have a French site that I want to parse, but am running into
I'm interested in microtypography issues on the web. I want a tool to fix:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.