I am trying to change my application to match the LockerService requirements and one of the issues I've ran into are using listeners that need access to the window object. I need to resize my components according to the size of the window, and this requires that I get window information like this.

var height = $(window).height();

This used to give the window height prior to LockerService, but now it returns 0, and the actual window object returned doesn't have a visible height field.


<aura:application >
    <ltng:require scripts="{!join(',', $Resource.jquery, $Resource.customjs)}"  />


    $A.getCallback(function() {
        $(window).resize(function() {
        function resizeContent() {
            var height = $(window).height()-244;
    }), 1

What is the correct way to fetch the window height now that things are quarantined with the whole secure DOM aspect and your JS only being to reach DOM objects that it created?

  • Hi @JasonLee, Did you get any workaround to fetch the window height/width which works even when LS is active?
    – SE_User
    Commented Sep 16, 2016 at 4:48
  • @SE_User : Nope.
    – Jason Lee
    Commented Sep 16, 2016 at 16:25

3 Answers 3


We've identified the issue within LockerService and it's in our queue to fix.

Please open a case with support and tell them to link to our internal work item W-3198557.

  • Any ETA on the fix for this? support closed my case so I don't know the progress.
    – Jason Lee
    Commented Jun 22, 2016 at 23:07
  • 1
    It's one of the items being worked on within the team, no exact ETA yet. Commented Jun 22, 2016 at 23:21
  • @Trevor Any updates on the fixes? we are also facing similar issues. Commented Jul 4, 2016 at 10:38
  • 1
    @Trevor - Is there a Known Issue available for this, which we can follow to get the update automatically?
    – VarunC
    Commented Jul 5, 2016 at 9:05
  • 3
    @SE_User This is fixed in the main Aura codebase, but is not currently planned to be released until Spring '17. Commented Sep 26, 2016 at 5:17

Just a thought on approaching this from a different angle: Remember that Locker will bar you from seeing DOM elements outside your Lightning namespace, but your components can still see one another.

There is a way to set dimensions relative to the height or width of the viewport in pure CSS using the vh and vw units. For example if your top-level component has this CSS:

    height: 90vh;

Then it means the element will size up to 90% of the available viewport. I can't be confident right now of expected results but at least in theory you can query that top-level component's height (whether through the DOM or events) and use it to trigger changes in other components' sizes.


document.height is obsolete: https://developer.mozilla.org/en-US/docs/Web/API/Document/height

jquery is doing some magic under the hood to preserve the API, but you could replace that line with var height = document.clientHeight, and that should work just fine inside the LockerService.

note: we will get someone to investigate what's going on with jquery internals anyways.

  • 1
    Hmm, document.documentElement.clientHeight seems to return the correct height when run manually inside my browser's console, but not from within the application.. It returns 0 just like $(window).height() .
    – Jason Lee
    Commented Jun 16, 2016 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .