Forum Moderators: open

Message Too Old, No Replies

Opening and Closing Windows in Javascript

I want to change the size and position of a window. Is it possible?

         

Web Designer Barbie

1:18 pm on Jun 14, 2004 (gmt 0)

10+ Year Member



I want to open our Intranet automatically when people log in (obviously, our IT guy can do that) but I need to specify the size of the window so it doesn't fill desk tops.

I tried making a page with a Javascript that would open the Intranet and then close itself. Only trouble is the pop-up warning box about windows closing themselves.

Is there a way to redirect and resize a window with all the specifications I want?

Sorry this is long. I'm a total beginner.

I put my first attempt in incase that's of help.

<!--
function win() {
window.open("URL","","height=400,width=800,left=150,top=100,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes");
}
function winClose() {
self.close()
}
//-->
</script>
</head>

<body onLoad=win() onBlur=winClose()>

BlobFisk

1:51 pm on Jun 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, Web_Designer_Barbie!

You can close a window using JavaScript without getting the security error only if that window was opened using javascript.

You can redirect using window.location.href and instead of opening a window, why not resize the current window using window.resizeTo(x,y) (where x is the horizontal size and y is the vertical size)?

One caveat about this method is that it's VERY annoying to the user! I would recommend that you allow the browser to be the size that it wants and allow the user ot resize it to the size that they want!

HTH

Web Designer Barbie

2:11 pm on Jun 14, 2004 (gmt 0)

10+ Year Member



That is just what I needed to know!

Many thanks for your advice about about the window resize. I'll make sure I get specific user feedback on that issue when I'm trialing it. And I promise never to use it again!

Thanks again!