Bugs item #454540, was opened at 2001-08-23 04:58 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105757&aid=454540&group_id=5757
Category: DynAPI 2 Browser-Specific Group: Verified Status: Open Resolution: None Priority: 5 Submitted By: Bernard Squale (bsquale) Assigned to: Nobody/Anonymous (nobody) Summary: getWidth() / Height() problems with NS6 Initial Comment: ... DynAPI.onLoad = function() { label1 = new Label('Some text') DynAPI.document.addChild(label1) // returns a value with IE/NS - Win32 alert(label1.getWidth()) label2 = new Label('Some text') d = new DynLayer() d.addChild(label2) DynAPI.document.addChild(d) // returns a value with NS4 / IE - Win32 //but 'null' with NS 6.1 - Win32, DyAPI 2.54 alert(label2.getWidth()) } ---------------------------------------------------------------------- Comment By: Eytan Heidingsfeld (eytanh) Date: 2001-12-06 13:54 Message: Logged In: YES user_id=50900 I have a partial solution. Since there is no sleep or wait in JS you can't have syncrouns code that works here so I wrote 2 async functions to that call a specified callback: /* Code snip */ DynLayer.prototype.cbGetContentWidth = function() { this.asyncw(this.elm.offsetWidth); this.elm.style.width = this.tw; } DynLayer.prototype.asyncGetContentWidth=function(result) { this.tw = this.elm.style.width; this.elm.style.width = "auto"; this.asyncw = result; setTimeout("DynObject.all ['"+this.id+"'].cbGetContentWidth()",1); }; DynLayer.prototype.cbGetContentHeight = function() { this.asynch(this.elm.offsetHeight); this.elm.style.height = this.th; } DynLayer.prototype.asyncGetContentHeight=function(result) { this.th = this.elm.style.height; this.elm.style.height = "auto"; this.asynch = result; setTimeout("DynObject.all ['"+this.id+"'].cbGetContentHeight()",1); }; /* End of Snip */ An example usage: function alertWidth(w) { alert(w); } if (is.ns6) myLayer.asyncGetContentWidth(alertWidth); ---------------------------------------------------------------------- Comment By: Robert Rainwater (rainwater) Date: 2001-12-06 11:53 Message: Logged In: YES user_id=16618 This is a bug in Mozilla. It doesn't set the offsetWidth immediately after creating the element. The only workaround at the moment is to use some sort of timeout and then retrieve the offsetWidth/Height. Rob ---------------------------------------------------------------------- Comment By: Eric LE ROY (lankou) Date: 2001-12-05 13:36 Message: Logged In: YES user_id=179452 Got the same problem....and this is why my dynTabStrip object does not work under NS6 I'm trying to find a solution Best Regards Lankou ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2001-11-10 21:49 Message: Logged In: NO I have a similar problem with NS6.2... I have the following: DynLayer.prototype.addPopupMenu = function (x,yAct,menuNames,menuLinks,menucolor,bordercolor) { var borderLayer = new DynLayer(null,(x- 4),yAct,0,0,bordercolor); DynAPI.document.addChild(borderLayer); var spacerLayer = new DynLayer (null,1,0,0,0,menucolor); borderLayer.addChild(spacerLayer); var menuLayer = new DynLayer (null,2,0,0,0,menucolor); spacerLayer.addChild(menuLayer); var menuText = ""; for (var i = 0; i < menuNames.length; i++) { menuText += "<A href=\"+menuLinks[i]+"\ class=\menu\>"+menuNames[i]+"</A><BR>"; } menuLayer.setHTML(menuText); var w = menuLayer.getContentWidth(); var h = menuLayer.getContentHeight(); menuLayer.setSize(w,h); spacerLayer.setSize((menuLayer.getWidth()+4), (menuLayer.getHeight()+2)); borderLayer.setSize((spacerLayer.getWidth()+2), (spacerLayer.getHeight()+1)); } In NS6.2, a thin layer loads without any text... the only workaround is to set borderLayer.setSize(200,200) or some other actual numbers. ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105757&aid=454540&group_id=5757 _______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://www.mail-archive.com/dynapi-dev@lists.sourceforge.net/