位置图层适用于IE而非Firefox / Safari [英] Position layers works in IE not Firefox/Safari

查看:51
本文介绍了位置图层适用于IE而非Firefox / Safari的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个菜单,当你鼠标悬停时会弹出不同的图层。似乎

在IE 6中正常工作。我使用javascript动态定位图层

,因为当用户调整浏览器窗口大小时菜单会移动。在

Firefox或Safari浏览器中,图层的位置是0,0无论是什么,不管是什么,马上就可以了。左上角。

任何人都可以告诉我原因吗?

这是我用于定位图层的javascript函数。

下面是URL我正在建设的页面。


/ * START FUNCTION

******************* ******************************* *** /

函数positionLayer(layerID,imageName) {


//将图层''layerID''置于与图像相同的坐标处

''imageName''

var xPos,yPos,myElement,myLayer;

if(document.layers){// NN4.x

xPos = document.images [imageName] .x;

yPos = document.images [imageName] .y;

}否则if(document.all){// IE4 / IE5

xPos = getXPos( document.images [imageName]);

yPos = getYPos(document.images [imageName]);


myLayer = document.all [layerID];

} else {// ass-u-me W3 DOM

myElement = document.getElementById(imageName);

xPos = myElement.offsetLeft;
yPos = myElement.offsetTop;


myLayer = document.getElementById(layerID);

}

/ *结束功能***************************************** ********* *** /
http://www.qcbt.com/qcbtinternet/unsecure/index.aspx

I have a menu that pops up different layers as you mouse over. Seems to
work OK in IE 6. I position the layers dynamically with javascript
because the menu moves when users resize their browser window. In the
Firefox or Safari browsers the position of the layers is 0,0 no matter
what, right off the bat. Top left corner.
Can any one tell me why?
Here is my javascript function for positioning the layers.
Below that is the URL of the page I am building.

/* START FUNCTION
************************************************** ***/
function positionLayer(layerID, imageName) {

// positions layer ''layerID'' at the same coordinates as image
''imageName''
var xPos, yPos, myElement, myLayer;
if(document.layers) { // NN4.x
xPos = document.images[imageName].x;
yPos = document.images[imageName].y;
} else if(document.all) { // IE4/IE5
xPos = getXPos(document.images[imageName]);
yPos = getYPos(document.images[imageName]);

myLayer = document.all[layerID];
} else { // ass-u-me W3 DOM
myElement = document.getElementById(imageName);
xPos = myElement.offsetLeft;
yPos = myElement.offsetTop;

myLayer = document.getElementById(layerID);
}

/* END FUNCTION ************************************************** ***/

http://www.qcbt.com/qcbtinternet/unsecure/index.aspx

推荐答案

ce******@yahoo.com 在2006年4月25日上午8:23发表以下声明:
ce******@yahoo.com said the following on 4/25/2006 8:23 AM:
我有一个菜单,当你鼠标悬停时会弹出不同的图层。似乎在IE 6中工作正常。我使用javascript动态定位图层
因为当用户调整浏览器窗口大小时菜单会移动。在Firefox或Safari浏览器中,层的位置是0,0无论是什么,马上就可以了。左上角。
任何人都可以告诉我原因吗?
I have a menu that pops up different layers as you mouse over. Seems to
work OK in IE 6. I position the layers dynamically with javascript
because the menu moves when users resize their browser window. In the
Firefox or Safari browsers the position of the layers is 0,0 no matter
what, right off the bat. Top left corner.
Can any one tell me why?




因为您的代码容易出错,所以不会按照您的想法行事,并且

你首先选择.all和.layers分支。


-

Randy

comp.lang.javascript常见问题 - http://jibbering.com/faq &新闻组每周

Javascript最佳实践 - http://www.JavascriptToolbox .com / bestpractices /



Because your code is error prone, doesn''t do what you think it does, and
you are taking the .all and .layers branches first.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


我明白了。感谢您提出的所有好建议。

I see. Thanks for all the great advice.


ce *** ***@yahoo.com 写道:
[snup]在Firefox或Safari浏览器中,层的位置
无论如何都是0,0,关闭蝙蝠。左上角。可以告诉我为什么?
[snup] In the Firefox or Safari browsers the position of the layers
is 0,0 no matter what, right off the bat. Top left corner. Can any
one tell me why?




我猜(从变量名称)你可能正在使用元素

命名为ID。哪些不是,哪些不适用于

GetElemtById(x)



I''m guessing (from the variable name) that you may be using element
names as IDs. Which they aren''t and which will therefore not work in
GetElemtById(x)


这篇关于位置图层适用于IE而非Firefox / Safari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆