Forum Moderators: open
I use a script that uses absolute positioning to place a certain <span> on a specific spot on the webpage.
This code works perfectly in IE, but it chokes if one uses FireFox:
e.parentElement.offsetTop
I get this error in FireFox:
"e.parentElement has no properties"
(
Here are some details.
e is the object of interest - a form textbox. It's passed to the function as "this", then becomes "e" inside the function. I'm trying to position the popup box (<span>) so that it's exactly aligned with the textbox.
)
Thanks!
NB
<input type=textbox onFocus="call_function(this)"...
Then inside the function I would get the position of the textbox:
function call_function(e){
top_position = e.offsetTop;
left_position = e.offsetLeft;
...
...
This used to give me the EXACT numbers I needed to position the <span> right next to the textbox.
Things changed once I put the textbox inside a centered table.
If I used the exact code as above, I would get the position of the textbox relative to the table (since the textbox is inside the table now), and not the position in the whole webpage. This would now allow me the position the <span> where I want it.
Because of that I also need to find out the offset positions of the <td> and <table> elements that the textbox resides in.
I tried doing something like this, and it works fine in IE, but it throws errors in FireFox:
function call_function(e){
top_position = e.offsetTop + [e.parentElement.offsetTop];
left_position = e.offsetLeft + e.parentElement.offsetLeft;
...
...
The code in brackets, which is supposed to refer to the <td> element (the brackets are not included in the original code), throws the error in FireFox, saying that "e.parentElement has no properties"
Any ideas?
Thanks!
NB