Javascript window resize for Netscape.

Posted on 2004-11-03
Last Modified: 2006-11-17
Hi I've been using this script (below) to autosize a popup window.
But this script only works in IE, I need it to work in IE and Netscape.
So I need this altered to work or a similar script that will work for both.

<script type="text/javascript">
function init(){

var width  =  document.all['contents'].clientWidth;
var height =  document.all['contents'].clientHeight;
window.resizeTo(width +10, height +25);


<body onLoad="init()">

Question by:bertmn
    LVL 13

    Expert Comment

    If 'contents' is an id, change all instances of document.all['contents'] to document.getElementById('contents')
    LVL 31

    Accepted Solution

    function init(){
     width= (document.body.clientWidth|| window.innerWidth)
     height= (document.body.clientHeight|| window.innerHeight)
     window.resizeTo(width +10, height +25)

    <body onLoad="init()">
    LVL 13

    Expert Comment

    or you can use:


    these return entire width and height of the actual cumputer screen


    Author Comment

    Thanks, works good.

    But as that window is refreshed it shrinks a little each time.
    Do you know why?
    LVL 31

    Expert Comment

    Thx for the points. One of the them does not include the toolbars/scrollbars (can not remmeber which one), try outerWidth as well. If you just want to increase the window size by an amount use window.resizeBy(10,25)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Both jQuery and Mootools offer some nice, easy to use scripts. Mootools is best known for their interactive slideshows and jQuery for their menus, but both have many other uses as well.   jQuery is basically a toolkit with many DOM (http://en.wik…
    This article shows how to read a single webpage's HTML into a string variable, and it also shows how to automate a sequence so you can read and process a list of webpages.  I was tasked with reading and parsing a series of webpages to collect some s…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now