I have this line of code
var width_client = Ext.getBody().getWidth(true);
and I get that Ext.getBody() is null. I asume that this check is doen before Ext.getBody() becames not null, but dont' know were or what to change.
Any idea how to solve this?
I use extjs 4.0.7
I have this line of code
var width_client = Ext.getBody().getWidth(true);
and I get that Ext.getBody() is null. I asume that this check is doen before Ext.getBody() becames not null, but dont' know were or what to change.
Any idea how to solve this?
I use extjs 4.0.7
Share Improve this question asked Jul 2, 2012 at 14:40 VladVlad 2,7737 gold badges52 silver badges106 bronze badges2 Answers
Reset to default 3You can access document.body when it is rendered. From your question I made a conclusion that your code was located inside <head>
. When this code is executed there is no <body>
rendered yet. You have to wrap your code by a function and pass this function to Ext.onReady (or Ext.onDocumentReady) method:
Ext.onReady(function() {
alert(Ext.getBody().getWidth(true));
});
Here is demo.
You have to wait until the page is loaded and ready. Try this.
Ext.onReady(function() { Ext.getBody().getWidth();})