1

I want to try change action on submit click and open new window itz open in new tab and worked but i want to open in new window

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "ReferralForm" }))

{

<input id="fbPost" type="submit" value="Post"  style="background-color:#314F8F;" class="white"/>

}

$('#fbPost').click(function () {
        $('#ReferralForm').attr({
            action: '@Url.Action("FacebookLogin", "Agent")',
          target: '_blank'
      });

1 Answers1

0

to get a popup instead of a new tab you have to set the dimensions of the window. I looked online a while ago and found this function

function PopupCenter(url, title, w, h) {
        // Fixes dual-screen position                         Most browsers      Firefox
        var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
        var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;

        width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
        height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;

        var left = ((width / 2) - (w / 2)) + dualScreenLeft;
        var top = ((height / 2) - (h / 2)) + dualScreenTop;
        var newWindow = window.open(url, title, 'model=yes,menubar=no,status=no,toolbar=no,location=no,width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);

        // Puts focus on the newWindow
        if (window.focus) {
            newWindow.focus();
        }
    }

I don't remember the source to give them credit. you then call the function like this.

var url = '@Url.Action("FacebookLogin", "Agent")';
PopupCenter(url, "Popup", 800, 600);    

I found this function since it determines your window size and sets the window so that it is centered when it opens. Hope this helps.

Matt Bodily
  • 6,403
  • 4
  • 29
  • 48
  • Open in new window but not fire facebooklogin action error occurred because post data after new window open $('#ReferralForm').attr({ action: '@Url.Action("FacebookLogin", "Agent")', target: '_blank' action are also gave to on this click so its not perform this function – Muhammad Sanaan Chattha Feb 26 '14 at 15:33