Reputation: 10998
I am facing a weird issue with firefox, I have a DIV tag with ID="popup_layer". I'm using Jquery to find this DIV which works fine :
var rightPosition=$j("#popup_layer")
But when I try to find the position of the DIV:
var rightPosition=$j("#popup_layer").position().left;
I get the following exception in Firebug:
[Exception... "Could not convert JavaScript argument arg 0 [nsIDOMViewCSS.getComputedStyle]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://localhost:20094/Scripts/CombineJS.ashx?JSFiles=/Scripts/jquery-1.2.6.min.js;%20%20%20%20/Scripts/PDP/newModalBox.js;%20%20%20%20/Scripts/CookieHelpers.js;%20%20%20%20popupLayer.js;%20%20%20%20/BE/Scripts/scripts.js; :: anonymous :: line 23" data: no]
Upvotes: 3
Views: 1979
Reputation: 3729
You cannot retrieve the dimensions or position of a DOM element with display:none
. By definition, the element is not supposed to exist rendered on the page, hence it takes no space.
I suggest leaving your element visible initially, getting the dimensions you want, then applying "display:none
" after you're done measuring it.
Alternatively you could use "visibility:hidden
" instead.
Upvotes: 3
Reputation: 10998
For some reason when i remove the style on my div it starts to work
<div id="popup_layer" style="display:none;">
To
<div id="popup_layer">
totally weird !
Upvotes: 1