0

I want to pop up a new page in the main page of my application . The location must be in center,can't be sizable, it shouldn't be opened as a new tab in the main page , the bar with the options for : closing,minimize/miximize shouldn't be there.

Here is my code:

  protected void Page_Load(object sender, EventArgs e)
        {
           HyperLink1.Attributes.Add("onclick", "window.open('WebForm1.aspx',null,'height=350, width=250,status= no, resizable= no, scrollbars=no, toolbar=no,location=center,menubar=no')");
        }

But....

  • It's sisable,location is not in not in the center of the page.

  • The page is opened in the main page but as a new tab.

  • I don't know how to remove the bar with : closing,maximize,minimize

Can someone help me?

Thanks

Jax
  • 977
  • 8
  • 22
  • 40
  • 2
    I don't believe you can control whether the browser opens it as a tab or as a new window. Nor should you. That's up to the browser and the end user to decide. – David Jul 12 '12 at 12:20
  • http://stackoverflow.com/questions/726761/javascript-open-in-a-new-window-not-tab already answers this question - effectively, David is right. – dash Jul 12 '12 at 12:22
  • Check this [link] http://stackoverflow.com/questions/1715201/how-can-we-disable-resizing-of-new-popup-window-in-firefox – HariHaran Jul 12 '12 at 12:32

1 Answers1

1

Try this:

protected void Page_Load(object sender, EventArgs e)
        {
           HyperLink1.Attributes.Add("onclick", "centeredPopup('WebForm1.aspx','myWindow','500','300','yes');return false");
        }


<script language="javascript">
var popupWindow = null;
function centeredPopup(url,winName,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
popupWindow = window.open(url,winName,settings)
}
</script>

For more details - see this

Kapil Khandelwal
  • 15,958
  • 2
  • 45
  • 52