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: Bruce Tennant (bluewlvrn) Date: 2002-02-14 01:03 Message: Logged In: YES user_id=419209 The current method in DynLayer 2.9 and 2.5.6. It actually breaks NS6.2. NS6.2 does not initially set style.width. So what happens is this. INITIALLY: offsetWidth = correct value set style.width = "auto" offsetWidth = still correct value set style.width = back to prior value (empty string) offsetWidth = 0 So in NS 6.2, you DON'T want to use the style.width trick because by manually setting style.width = '' (empty string) it resets offsetWidth to 0. I added the following statements to getContentWidth/Height for NS if (dynapi.ua.ns4) return this.doc.width; else if (dynapi.ua.ie) { if (dynapi.ua.platform=="mac") return this.elm.offsetWidth; return parseInt(this.elm.scrollWidth); } // added by BT 2/13/2002 else if (dynapi.ua.ns6) { return parseInt(this.elm.offsetWidth); } // ----- else { .... Now after reading this bug report, I may need to add a minor version check rather than just for ns6. It looks like the NS bug was fixed in 6.2. ---------------------------------------------------------------------- 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/