Friday, 15 February 2013

javascript - Dynamic Div Height Calculation - JQuery/AJAX -


I have written a small lightbox plugin for jQuery (yes, there are many ready-made packages - unfortunately, Co. Does not like any of them).

I have a small problem - I am using .load () to load dynamic flash content in the lightbox device. I am enclosing Dim in DOM, determining hidden visibility, and using .outerHeight (true) and .outerwidth (true) to achieve dimensions. In Internet Explorer, I'm getting a height of 61px (margin + 1px).

Context: Content Container is already attached to body dom fr

  var remote = $ (document.createElement ("div")); Remote.css ("margin", "30px"); Var loadURL = $ (this) .attr ('href'); If (typeof (isImage) == "undefined" |! IsIge) {console.log ("Loading" + loadURL); ContentContainer.append (remote); Remote.load (loadURL, function) (contentContainer.css ("left", (currWindow.width / 2) - (contentContainer.outerWidth (true) / 2) .css ("top", document.body.scrollTop + (CurrWindow.height / 2) - (contentContainer.outerHeight (true) / 2)); overlay.css ("visibility", "visible"); Content Container CSS ("Visibility", "Visible");}); }  

With a set height and width, a basic div that is being loaded in a remote.

Any suggestions? I think there is some stupidity about it when I am trying to calculate the height and width. Although it worked with an original image ...

Josh

Around Try the contents of the callback in a window.setTimeout will wait to open the current call stack before executing it with 0 milliseconds. In my experience, this callback fixes some IE issues over time, when the browser event executes the callback after the fire, but before that IE redens the window.


No comments:

Post a Comment