Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Window Height Issue

Hey Guys, loved the idea of Titanium when I first read about it, dived right in and thought it was great I could use my own IDE + Titanium Developer. Since I started some very basic tests, I have been getting totally stumped by a number of seemingly minor problems compounded by lack of examples and tutorials (desktop).

Here's a quick example.

      window.onload = function()
        var window = Titanium.UI.getCurrentWindow;
        window.setHeight(300); // Set the window height to 300 pixels.

The code above is pulled straight out of the docs (http://developer.appcelerator.com/apidoc/desktop/latest/Titanium-module) and should just set the window height when the program compiles.

When compiled however, the webkit inspector says "TypeError: Result of expression 'window.height' [undefined] is not a function."

On another note, none of the KitchenSinkDesktop examples for notifications work and result in similar errors, but thats for another post.

I could be totally missing something though, so please feel free to point out what it could be. Tested this on Windows 7 32bit and 64bit.


— asked June 15th 2010 by David Rugendyke
  • desktop
  • win32
  • windows7
1 Comment
  • Hi David
    I'm just reading a bit through the Ti Desktop questions. You probably figured out by now:

    I think you have to call Titanium.UI.getCurrentWindow() instead of Titanium.UI.getCurrentWindow.


    — commented July 17th 2010 by Enrique Erne

3 Answers

  • window.height is not a function, it's a property… try window.height = 300;

    — answered June 15th 2010 by Michael Steuer
    1 Comment
    • Thanks for the quick response Michael. In my original code example, I typed in the wrong syntax for what I was actually using, which was window.setHeight(300). I've fixed that up in the original comment.

      Found the solution was to use Titanium.UI.currentWindow instead of Titanium.UI.getCurrentWindow;

      Thanks for your help though!

      — commented June 15th 2010 by David Rugendyke
  • i think it should be windows.height = 300;

    — answered June 15th 2010 by Peter Lum
  • what if one wants to re-size the window smoothly using jquery effects ?!

    — answered July 20th 2011 by Mohamed Almasry
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.