Jump to content
xisto Community
epox

How Can I Resize The Web Browser? using javascript

Recommended Posts

how can i resize the window with javascript, and how to center an element in the browser window?thanks a lot!!! :P

Notice from BuffaloHELP:
Corrected title spelling. This is more appropriate in Programming section. Please, please make sure that you post in the right section.
Edited by BuffaloHELP (see edit history)

Share this post


Link to post
Share on other sites

If I went to a site and it resized my browser window without asking me, I'd leave that site immediately, so in other words, I'd think carefully about implementing something like that.

Share this post


Link to post
Share on other sites

how can i resize the window with javascript

If this is what you mean then no objections over here, although it may be an idea to tell the user's what you did (so they don't think they've been hacked) :P

 

Here's the code to maximize the window:

 

<script language="javascipt" type="text/javascript">self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);</script>

Here's an explaination of the code:

 

self.moveTo(0,0); - Moves the window to the top left land corner (x=0,y=0)

self.resizeTo(screen.availWidth,screen.availHeight); - Tells javascript to resize the window to the available screen width and height.

 

And yes you can adapt this code:

 

<script language="javascript" type="text/javascript">self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight/2);</script>

The above will make the window fill up the top-left quarter of the screen.

 

<script language="javascript" type="text/javascript">self.moveTo(0,0);self.resizeTo(screen.availWidth/2,screen.availHeight/2);</script>

... And this the top half

 

an element in the browser window?

 


What do you mean by element? An image for example. If you do I'll get back to you on it B)

Share this post


Link to post
Share on other sites

Sorry for double posting but I've found the answer :P

This code will show you how to put an image (maybe a piece of flash, haven't tested it yet, into the middle of the page)

<table align="center" height="100%" width="100%"><tr><td valign="middle" align="center"><img src="img.jpg" alt=""></td></tr></table>

It's the best I can come up with and it works. If this isn't what you wanted please say...

Share this post


Link to post
Share on other sites

For a time, I stopped coding web pages (and testing browsers) to concentrate on my BA degree. I've started back up again and found using the "screen.ResizeTo" javascript "command" using screen.AvailWidth & Height, IE v8 would respond to the "moveTo" command; but, not resize to the whole window as I requested. Is this a new safeguard added like the permenant location bar which, at one time, you could turn off? Could there be another script on the page simply preventing the behavior?

-reply by Jim Farrell

Share this post


Link to post
Share on other sites
Expanding layoutHow Can I Resize The Web Browser?

How can I create a webpage in expand. That mean fit to every browser.

For this I can give div height, width in percent but, in case of image hoe it will fit in proper div in percent.

-question by Vivek

Share this post


Link to post
Share on other sites
browser size changedHow Can I Resize The Web Browser?Hi,Kids were on the pc last week and now when I open explorer the window fills the whole screen including the task bar! Obviously something either infiltrated the pc or they accepted a setting change. Can anyone tell me how to change it back so that when I click the maximize button on the browser it fills the screen but NOT the task bar? Thanks in advance for any help you might provide!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.