I am writing a program that has a sort of login window, i was looking for a way to resize the window so that it doesn't open so big with empty space. Any help is appreciated

Dani AI

Generated

Short answer: the sizing is controlled by client-side code. and were on the right track recommending a JavaScript window, but there are a few common reasons the new window still looks “normal”:

  • Modern browsers often open a new tab instead of a separate window and ignore size/position hints.
  • Popup blockers will stop or alter scripted opens unless they come from a direct user action (click).
  • Calling the open from onload or without a user gesture can be blocked or ignored.

Checks and quick troubleshooting

  • Verify the open runs as the immediate result of a user click. If you trigger it on page load it may be blocked.
  • Test in multiple browsers; behavior varies and some ignore sizing parameters.
  • If you need server-side control (ASPX.cs), emit the client script so it runs in the browser (use ClientScript.RegisterStartupScript or ScriptManager.RegisterStartupScript if you have UpdatePanels).

A more reliable approach (recommended)
Instead of trying to force a browser window size, create an in-page modal dialog you control with CSS/JS. That always renders at the size you want and avoids popup blockers. Example using jQuery UI:

<div id="loginDialog" title="Login" style="display:none">
  <!-- login form markup -->
</div>

<script>
function openLoginModal() {
  $("#loginDialog").dialog({ width: 420, height: 300, modal: true });
}
</script>

From ASP.NET code-behind you can trigger that after render:

ClientScript.RegisterStartupScript(this.GetType(), "openLogin", "openLoginModal();", true);

References and notes

Recommendation: use an in-page modal for reliable sizing; reserve window.open only when you accept that browsers may ignore sizing or open a tab.

Recommended Answers

All 6 Replies

you can open a new window using javascript window.open method, it has parameter collection to resize the window.
you can search google with javascript window open resize

I am writing a program that has a sort of login window, i was looking for a way to resize the window so that it doesn't open so big with empty space. Any help is appreciated

window.open("ur"l, "title", "height=what you want,width=what you want")

you can add to the last string more settings of the opened window like status(yes/no), toolbar (yes/no), menubar(yes/no) and more...
you can check the list of available settings in this link:
http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx
in the "sFeatures" section.

enjoy

window.open("ur"l, "title", "height=what you want,width=what you want")

you can add to the last string more settings of the opened window like status(yes/no), toolbar (yes/no), menubar(yes/no) and more...
you can check the list of available settings in this link:
http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx
in the "sFeatures" section.

enjoy

I don't think i understand how to use this. Does this go in my Body tag or in the file?

I don't think i understand how to use this. Does this go in my Body tag or in the file?

to your body tag in a script tag

<body>

<script language="javascript">
window.open("","","")

</ script>
</ body>

to your body tag in a script tag
<body>

<script language="javascript">
window.open("","","")

</ script>
</ body>

I added this into my body tag and it still opens up with the normal window size.

I added this into my body tag and it still opens up with the normal window size.

post your code here please (the html source)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.