Gabriel Souza
Gabriel Souza

Reputation: 11

window.open() isn't opening with the height I pass to it

I'm trying to set height=200 and width=200 on a window, but all I get is the standard page size. I've tried other height and width sizes but it keeps opening the same size.

Here's the code:

Page.ClientScript.RegisterClientScriptBlock(
    Page.GetType(), 
    "cadastrarProduto", 
    "window.open('CadastroProduto.aspx','height=200, width=200',false)", 
    true);

cadastrarProduto is the string key I chose. CadastroProduto.aspx is the page I'm redirecting with the script.

I'm trying to do this on asp.net, if there is better way to PopUp a window I would like to know.

Upvotes: 1

Views: 458

Answers (3)

George Birbilis
George Birbilis

Reputation: 2930

You seem to be missing the name parameter (2nd - it's optional, but that means you can pass an empty value, not just skip it). Quoting https://www.w3schools.com/jsref/met_win_open.asp below:

Optional. Specifies the target attribute or the name of the window. The following values are supported:

_blank - URL is loaded into a new window. This is default
_parent - URL is loaded into the parent frame
_self - URL replaces the current page
_top - URL replaces any framesets that may be loaded
name - The name of the window (Note: the name does not specify the title of the new window)

Upvotes: 0

user8905879
user8905879

Reputation:

try it it will work

Response.Write("<script> window.open('" + "CadastroProduto.aspx" +
 "','_blank','toolbar = yes, width = 100, height = 100'); </script>");

Upvotes: 1

TARUN KUMAR
TARUN KUMAR

Reputation: 141

window.open(URL, name, specs, replace)

name is optional. It can be empty. So, have a blank parameter and then add height value.

window.open('CadastroProduto.aspx',' ','height=100, width=100',false)

Upvotes: 0

Related Questions