Jump to content
  • 0

Не работает код в FireFox


dmitry.vl
 Share

Question

Подскажите пожалуйста почему может не работать в FireFox:

В ИЕ и Опере показывает Layer1 точно там где надо... а в лисе тупо в левом верхнем углу...

Заранее спасибо :)

function test_layer()
{

obj = document.getElementById("hap_right");
pos = getAbsolutePos(obj);

x = pos.x + 249;
y = pos.y + 105;

document.getElementById("Layer1").style.left = x - 104;
document.getElementById("Layer1").style.top = y;
document.getElementById("Layer1").style.visibility = "visible";
}

function getAbsolutePos(el)
{
var r = { x: el.offsetLeft, y: el.offsetTop };
if (el.offsetParent)
{
var tmp = getAbsolutePos(el.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
}

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Посмотрите пример

function getElementPosition(offsetTrail)
{
var offsetLeft = 0;
var offsetTop = 0;
while(offsetTrail) {
offsetLeft += offsetTrail.offsetLeft;
offsetTop += offsetTrail.offsetTop;
offsetTrail = offsetTrail.offsetParent;
}
return { left:offsetLeft, top:offsetTop }
}

function hideFootnotes() {
var div = document.getElementById('current_footnote');
div.className = 'footnote_new';
div.style.display = 'none';
return false;
}

function showFootnote(evt, id) {
var winWidth = document.body.clientWidth;
var evt = evt || window.event;
var o = evt.target || evt.srcElement;
var div = document.getElementById('current_footnote');
var coords = getElementPosition(o);
var text=id.getAttribute("description");
div.innerHTML =text;
div.className = 'footnote_new_active';
div = document.getElementById('current_footnote');
var w = 220;
div.style.top = (coords.top + o.offsetHeight + 3) + 'px';
if((winWidth - coords.left) < w)
div.style.left = (coords.left - (w - (winWidth - coords.left - 20)))+ 'px';
else
div.style.left = coords.left + 'px';
div.style.display = 'none';
div.style.display = 'block';
evt.cancelBubble = true;
return false;
}

работает везде

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy