Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Open browser in predefined width & height?

On starting an html page, how can I force the browser to open as a window of, lets say, 300 x 300 pixels? I know how to open a second window with predefined mesures, so that is not the question. I'm talking about the first one. Can it also be centered on the screen?
0
Zoroaster
Asked:
Zoroaster
  • 4
  • 2
  • 2
1 Solution
 
EpsylonCommented:
Use javescript method window.open like this:

<FORM NAME="myform">
<INPUT TYPE="button" NAME="Button1" VALUE="Open Sesame!"
   onClick="window.open
   ('sesame.html', 'newWin', 'scrollbars=yes,status=yes,width=300,height=300')">
</FORM>


============================================================

[windowVar = ][window].open("URL", "windowName", ["windowFeatures"])

windowVar is the name of a new window. Use this variable when referring to a window's properties, methods, and containership.

URL specifies the URL to open in the new window.

windowName is the window name to use in the TARGET attribute of a <FORM> or <A> tag. windowName can contain only alphanumeric or underscore (_) characters.

windowFeatures is a comma-separated list of any of the following options and values:

   toolbar[=yes|no]|[=1|0]
   location[=yes|no]|[=1|0]
   directories[=yes|no]|[=1|0]
   status[=yes|no]|[=1|0]
   menubar[=yes|no]|[=1|0]
   scrollbars[=yes|no]|[=1|0]
   resizable[=yes|no]|[=1|0]
   width=pixels
   height=pixels

0
 
ZoroasterAuthor Commented:
I was affraid to get this kind of answer... Although well documented, this was not the question. I stated clearly that I want to open the FIRST page with predefined mesures, NOT the second or third. Can you review this?
0
 
EpsylonCommented:
Guess the only way to do this is to write an ActiveX component that uses the MoveWindow api function. But then you will have annoying security warnings etc.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ZoroasterAuthor Commented:
OK, I'll leave the question open for a few more days, awaiting some more comments. If there is nog solution, I'll grade this for you. Thanks anyway for your help.
0
 
hide011199Commented:
you can change current windows size(for NN4 or IE4), below.


<HTML>
<HEAD>
<SCRIPT Language="JavaScript">
<!--
scrWidth = screen.width;
scrHeight = screen.height;
window.resizeTo(300,300);
window.moveTo(scrWidth/2-150, scrHeight/2-150);
// -->
</SCRIPT>
</HEAD>


<BODY>
</BODY>
</HTML>

thanks.
0
 
ZoroasterAuthor Commented:
Yes, Hide, this is exactly what I want. I'll reopen the question for you. Sorry Epsylon, but I'll have to reject your answer. Thanks anyway for your help.
0
 
hide011199Commented:
you can change current windows size(for NN4 or IE4), below.

<HTML>
<HEAD>
<SCRIPT Language="JavaScript">
<!--
scrWidth = screen.width;
scrHeight = screen.height;
window.resizeTo(300,300);
window.moveTo(scrWidth/2-150, scrHeight/2-150);
// -->
</SCRIPT>
</HEAD>


<BODY>
</BODY>
</HTML>

thanks.

0
 
ZoroasterAuthor Commented:
This works very fine indeed. Thanks, hide.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now