Solved

Window resize - cross browser

Posted on 2007-12-02
11
1,215 Views
Last Modified: 2013-11-19
Hi, I am looking for a way to accurately resize the browser to display exactly a 800x600 webpage, with no surrounding white space around on all major browsers.  Possible?  I have tried js window.resizeTo(810,772) which seems to work on FF but has a different result in IE.

Look forward to hearing from you.
0
Comment
Question by:Treder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20392435
Just so you know: many browsers nowadays has resizing of the window disallowed by default.

If you specify a size when you use window.open, that size is the size of the working area.

If you want to use window.resizeTo, you have to calculate the difference between the window size and the workarea size. Resize the window to something that is close to what you want, then use document.partentNode.clientWidth and .clientHeight to find out the size of the working area. Calcualte the difference between the size that you specified and the size that you got, and call resizeTo again with the adjusted values.
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20392438
Correction: That is document.body.parentNode.clientWidth.
0
 

Author Comment

by:Treder
ID: 20393095
Thanks for the reply.  I am no programmer, is there any working code out there for this?  I have explored many a google on it, but have not come across anything that looks to work.  
0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 20393178
You don't have to be much of a programmer to write the code from my description above. :)

Try this out. I am not 100% certain that it works to resize twice without returning control to the browser inbetween, though.
var w = 800;
var h = 600;
window.resizeTo(w, h);
var w2 = document.body.parentNode.clientWidth;
var h2 = document.body.parentNode.clientHeight;
var dw = w - w2;
var dh = h - h2;
window.resizeTo(w + dw, h + dh);

Open in new window

0
 
LVL 3

Expert Comment

by:anandhariharan
ID: 20491002
This code across browsers. Quite similar to GreenGhost's comment.
var w = 810;
var h = 772;
window.resizeTo(w,h);
function winResize(){
  window.resizeTo(w,h);
}
 
<body onload="winResize()">

Open in new window

0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20492091
anandhariharan, that code assumes a specific difference between the browser window size and the workarea size. That only works for someone who has the exact same combination of operating system, system version, desktop theme, browser and browser toolbar settings as you have...
0
 
LVL 3

Expert Comment

by:anandhariharan
ID: 20494592
GreenGhost, I have just given the size mentioned by the author who posted this query. It can always be changed according to what the author wants. To be very specific for a 800x600 resolution, the width of the browser should be 777px.

The Author can also mention "window.screen.width" if the design is fluid.

Treder, What say?
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20495455
> GreenGhost, I have just given the size mentioned by the author who posted this query.

Obviously you didn't understand the question, as all you did was to post some code that does exactly the same thing as the code Treder already posted in the question.

> It can always be changed according to what the author wants.

The point is that it can't.
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20548639
Checking back to see if you had any progress?
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20953153
Forced accept.

Computer101
Community Support Moderator
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question