SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to set width/height of window content area w/ W3C

    I am currently using a popup window to establish the dimensions of a window, specifically based on the the width/height of the content area.

    I would prefer to simply resize it and avoid the need for a popup altogether, but this is made difficult due to inconsistancies as to how resizeTo() accounts for whatever toolbars are 'on' which varies from browser to browser and platform to platform.

    The site is coded to W3C (X/HTML, CSS) and the DOM/DHTML content is gradually being rewritten in accordance with the W3C DOM.).

    The W3C DOM property to get/set the window content area dimensions are:

    Code:
    window.innerWidth
    window.innerHeight
    ...neither of which get any response in any of the W3C DOM compliant browsers currently available.

    So, the question is how do I reliably set the dimensions of the content area using code that can be understood by IE5+/Opera5+/Gecko?

    I want to get rid of the popup, but it seems the lack of support for the DOM resize method (window.innerHeight,...) is tying me to using a popup*.
    (* control over the window/content area size is non-negotiable.)


    Am I doing something wrong? Am I using the window.innerWidth method wrongly or something?

    I'm using it as prescribed at the Mozilla/Gecko DOM Window references page.

    Is there some other way?

    TIA
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  2. #2
    SitePoint Zealot jonsteele's Avatar
    Join Date
    Jan 2001
    Location
    Toronto
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried the resizeBy(x,y) or resizeTo(x,y) methods?

    You can get some more info here: http://www.wsabstract.com/javatutors/advwin5.shtml

  3. #3
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to set width/height of window content area w/ W3C

    Originally posted by jonsteele
    Have you tried the resizeBy(x,y) or resizeTo(x,y) methods?

    You can get some more info here: http://www.wsabstract.com/javatutors/advwin5.shtml
    Originally posted by Bill Posters
    ...I would prefer to simply resize it and avoid the need for a popup altogether, but this is made difficult due to inconsistancies as to how resizeTo() accounts for whatever toolbars are 'on' which varies from browser to browser and platform to platform....
    Thanks jonsteele, but as you seem to have missed in my original post I have already tried resizeTo().

    The problem with that method is that Windows browsers include the toolbars, etc... in the dimensions whereas Macs don't.
    Seeing as I will have no way of knowing which toolbars are on or off* it becomes impossible (?) to ensure that I make the window just the right size for my content.
    (*without using a popup, which is exactly the thing I am trying to avoid here)

    I'm currently using a simple DIY script to resize and center some of my windows...

    Code:
    function prepMe(winW,winH) {
    
    if (navigator.platform.indexOf('Win') != -1)  {
    	winW = (parseInt(winW) + 10)
    	winH = (parseInt(winH) + 29)
    	}
    	window.resizeTo(winW,winH)
    
    	winX = (window.screen.availWidth - winW) / 2
    	winY = ( (window.screen.availHeight - winH) / 2 )
    
    	window.moveTo(winX,winY)
    }
    ...which accounts for the fact that Windows OS includes the titebar in the dimensions (and makes the window larger accordingly), but this is currently only being used on popups which I have set to have everything (apart from the toolbar - off).
    I can predict how much the window dimensions need to increased in this case.

    I want to use resize the window and guarantee that the content area is the right size regardless of whatever toolbars, etc... are visible.

    I also want to achieve this in a way that works for all W3C DOM compliant browsers which presumably would entail using the W3C DOM.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •