473,503 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Position layers works in IE not Firefox/Safari

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

Apr 25 '06 #1
12 2251
ce******@yahoo.com said the following on 4/25/2006 8:23 AM:
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?


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/
Apr 25 '06 #2
I see. Thanks for all the great advice.

Apr 26 '06 #3
ce******@yahoo.com wrote:
[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?


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)
Apr 26 '06 #4
ce******@yahoo.com wrote :
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?


The Magpie got it: you are passing the image name when you should be
passing the id attribute if you use getElementById or the image name
with document.images collection. You can't mix the 2.

What Randy told you is also correct and good. The first branch of a
if..else..else block should be the W3C DOM support.

function positionLayer(layerID, imageName)
{
var xPos, yPos, myElement, myLayer;

if(document.images)
// DOM 2 HTML compliant
// http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-90379117
{
xpos = getXPos(document.images[imageName]);
yPos = getYPos(document.images[imageName]);
};
}

I suggest you drop the document.layers block unless you can test the
function+DHTML menu with NS 4.x and if you know that there are still
users using it... and even there, I'd never recommend using NS 4.x to
reach a bank website. NS 4.x users represent less than 0.5% worldwide:
it's definitely not worth the huge trouble coding for NS 4.x involves.

I'm going to add that your webpage is full of deprecated markup code,
uses transitional DTD and is full of nested tables: there is no reason
for all this.

Table-based webpage design versus CSS-based webpage design: resources
http://www.gtalbot.org/NvuSection/Nv...CSSDesign.html

HTML Tidy extension for Firefox users
http://users.skynet.be/mgueury/mozilla/index.html

Why we won't help you
http://diveintomark.org/archives/200..._wont_help_you

HTML markup validator
http://validator.w3.org/

Gérard
--
remove blah to email me
Apr 26 '06 #5
Gérard Talbot wrote:
Table-based webpage design versus CSS-based webpage design: resources
http://www.gtalbot.org/NvuSection/Nv...CSSDesign.html


"The reports of my death have been greatly exaggerated"
-- <table>

A single, clean layout table for a page often is still the best way to go.
Trying to do some things with pure CSS that can be done trivially with a
table layout often involves CSS hacks, doctype-dependencies, and bulky
"wrapper" <div>'s, not to mention a steep learning curve for most.

For developers who understand the issues and are not zealots for either
side, a common-sense marriage of tables and CSS is the true nirvana.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Apr 26 '06 #6
"Matt Kruse" <ne********@mattkruse.com> wrote in
news:e2********@news3.newsguy.com:

totally OT, but i love your "validations.js" script and use it often!
Apr 26 '06 #7
Matt Kruse wrote :
Gérard Talbot wrote:
Table-based webpage design versus CSS-based webpage design: resources
http://www.gtalbot.org/NvuSection/Nv...CSSDesign.html
"The reports of my death have been greatly exaggerated"
-- <table>

A single, clean layout table for a page often is still the best way to go.


It depends. In the abstract, I can't say. In general, I can't say. But I
am saying there is no justification for nested tables. And I'm saying
that the webpage I saw
http://www.qcbt.com/qcbtinternet/unsecure/index.aspx
was clearly and definitely misusing tables, abusing tables.
It looks entirely not professional.
Trying to do some things with pure CSS that can be done trivially with a
table layout often involves CSS hacks,
It shouldn't involve CSS hacks. Even Microsoft asked people to stop
using CSS hacks.
Call to action: The demise of CSS hacks and broken pages
http://blogs.msdn.com/ie/archive/2005/10/12/480242.aspx

doctype-dependencies,
It depends what you're referring to here.

and bulky "wrapper" <div>'s, not to mention a steep learning curve for most.

No argument with me on this. Too many <div>'s strongly suggest
inexperience and/or lack of knowledge.

Web Page Development: Best Practices
http://developer.apple.com/internet/...estwebdev.html

"Classitis and Divitis
A common error of beginning CSS coders is to use far too many <div> tags
and class attributes"
For developers who understand the issues and are not zealots for either
side, a common-sense marriage of tables and CSS is the true nirvana.


What about simply suggesting to use an already proven, simple and
reliable CSS templates which are available, easy to implement, easy to
understand, easy to upgrade if needed, using valid markup code and a
strict DTD?

CSS webpage templates
http://www.gtalbot.org/NvuSection/Nv...bpageTemplates

Gérard
--
remove blah to email me
Apr 27 '06 #8
Matt Kruse wrote:
Gérard Talbot wrote:
Table-based webpage design versus CSS-based webpage design: resources
http://www.gtalbot.org/NvuSection/Nv...CSSDesign.html
"The reports of my death have been greatly exaggerated"
-- <table>

A single, clean layout table for a page often is still the best way to go.


No, it is not. For example, it renders slower and it does not follow
accessibility standards.
Trying to do some things with pure CSS that can be done trivially with a
table layout often involves CSS hacks, doctype-dependencies, and bulky
"wrapper" <div>'s,
No, it does not.
not to mention a steep learning curve for most.
You would prefer to keep people incompetent, so that you can "sell" them
your software? I see.
For developers who understand the issues and are not zealots for either
side, a common-sense marriage of tables and CSS is the true nirvana.


A true nirvana for you. Because you can follow your natural laziness, can
avoid learn anything new, and can better "sell" your software. To the
disadvantage of everybody else. There is a word for that: antisocial.
PointedEars
Apr 27 '06 #9
Thomas 'PointedEars' Lahn said the following on 4/27/2006 9:27 AM:
Matt Kruse wrote:
Gérard Talbot wrote:
Table-based webpage design versus CSS-based webpage design: resources
http://www.gtalbot.org/NvuSection/Nv...CSSDesign.html "The reports of my death have been greatly exaggerated"
-- <table>

A single, clean layout table for a page often is still the best way to go.


No, it is not. For example, it renders slower and it does not follow
accessibility standards.


Yes it is. You are just too ignorant to realize/accept it.
Trying to do some things with pure CSS that can be done trivially with a
table layout often involves CSS hacks, doctype-dependencies, and bulky
"wrapper" <div>'s,


No, it does not.


Depends on who tries to create it and the knowledge level of that
person. And yes, when going from tables to CSS most newbes do div overkill.
not to mention a steep learning curve for most.


You would prefer to keep people incompetent, so that you can "sell" them
your software? I see.


Matt sells software? Thats news to me. Or, are you pulling crap out of
your ass again?
For developers who understand the issues and are not zealots for either
side, a common-sense marriage of tables and CSS is the true nirvana.


A true nirvana for you. Because you can follow your natural laziness, can
avoid learn anything new, and can better "sell" your software.


There you go again. Can you post a URL to this "software" you keep,
wrongly, referring to?
To the disadvantage of everybody else. There is a word for that: antisocial.


You, calling people antisocial? Thank you for my laugh of the week.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 27 '06 #10
Thomas 'PointedEars' Lahn wrote:
A single, clean layout table for a page often is still the best way
to go.

No, it is not. For example, it renders slower and it does not follow
accessibility standards.


It does neither.
In fact, I've seen CSS-only layouts that render slower than a single table.
Saying that a single table will render slow is absurd, unless you think in
nanoseconds.
Accessibility is a concern, but the information in a table layout still
flows correctly top-to-bottom in the source. Since table layouts have been
used for years, any accessibility tool should be able to deal with a simple
table layout.
Trying to do some things with pure CSS that can be done trivially
with a table layout often involves CSS hacks, doctype-dependencies,
and bulky "wrapper" <div>'s,

No, it does not.


Your lack of anything resembling an argument does not help your "point".
If CSS layouts didn't require hacks we tables like this:
http://www.dithered.com/css_filters/css_only/index.php wouldn't exist.
not to mention a steep learning curve for most.

You would prefer to keep people incompetent, so that you can "sell"
them your software? I see.


The reality is that people don't have hours and hours to spend learning
every new web technique. Some of us have families and jobs. And the truth
is, learning to use CSS to the degree required to do complex layouts is
something many people don't have time to do.

And once again, despite your push towards people doing things the "right"
way, your own web site reoutinely demonstrates the _opposite_ of what you
preach. Is your lack of ability to do things the "right way" incompetence on
your part? Or just laziness?

I've used CSS extensively for complex layouts without tables. I'm very
familiar with the arguments for and against using tables for layouts. I'm
very familiar with the nuances of CSS and how they affect real-world
development. Although I use a single layout table on
http://www.javascripttoolbox.com/ you are welcome to look at my CSS
techniques there and critique all you want. I think you will find that my
standards are far above other sites like, oh, say, http://pointedears.de/ .
For developers who understand the issues and are not zealots for
either side, a common-sense marriage of tables and CSS is the true
nirvana.

A true nirvana for you. Because you can follow your natural
laziness, can avoid learn anything new, and can better "sell" your
software. To the disadvantage of everybody else. There is a word
for that: antisocial.


You are truly a piece of work, Mr. Lahn. I am neither lazy nor anti-social
nor do I "sell" my software nor am I disadvantaging anyone else.

You, sir, are a troll, and just barely above VK in the amount of value that
you add to this newsgroup. If the word "anti-social" describes anyone here,
it would be you. Maybe you don't interact with humans in the real world, but
if you behave in real life as you do here, I don't imagine that many people
would find your company welcome. You are judgemental, insulting, demeaning,
elitist, anal retentive, combative, and unpleasant.

Do me a favor and add me to your kill file or adjust my score or whatever it
is that you do, so you never need to be bothered with seeing or responding
to my posts again.

Have a nice day!

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Apr 27 '06 #11
Matt Kruse wrote:
You, sir, are a troll, and just barely above VK in the amount of
value that you add to this newsgroup. If the word "anti-social"
describes anyone here, it would be you. Maybe you don't interact with
humans in the real world, but if you behave in real life as you do
here, I don't imagine that many people would find your company
welcome. You are judgemental, insulting, demeaning, elitist, anal
retentive, combative, and unpleasant.
Do me a favor and add me to your kill file or adjust my score or
whatever it is that you do, so you never need to be bothered with
seeing or responding to my posts again.


I probably should have prefaced that with "Jane, you ignorant slut" ;)

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Apr 27 '06 #12
Matt Kruse wrote :
If CSS layouts didn't require hacks we tables like this:
http://www.dithered.com/css_filters/css_only/index.php wouldn't exist.
I have never recommended CSS hacks or anything close to any of this.
Quite on the contrary.
A good web design would stay away from any/all of these hacks. As soon
as such flaws in browsers are corrected by new versions, then the
webpage code (markup and CSS) has to be modified and adjusted while
maintaining the old hacks in place for the people not upgrading their
browsers. All of this is non-sense, more and more difficult to manage,
to maintain.
not to mention a steep learning curve for most. You would prefer to keep people incompetent, so that you can "sell"
them your software? I see.


The reality is that people don't have hours and hours to spend learning
every new web technique. Some of us have families and jobs. And the truth
is, learning to use CSS to the degree required to do complex layouts is
something many people don't have time to do.


I'd reply roughly the same again. First, use a decent, web standards
compliant HTML editor: Nvu 1.0 is certainly a defendable choice. On the
other hand, Front Page has now been discontinued by Microsoft itself.

Then, search for proven, reliable, cross-browser and standards-oriented
CSS templates: I have offered a list already.
The best CSS template is the one that gets explained step by step in a
tutorial. So that way, one can reach both goals: usage of the template
and understanding (with the independence that it brings) of
using/adjusting/upgrading it later.

And once again, despite your push towards people doing things the "right"
way, your own web site reoutinely demonstrates the _opposite_ of what you
preach.
Several people have compared Thomas Lahn's own adamant preaching, harsch
admonishing posts with his own webpage design practices. The guy is not
only abrasive, arrogant but, more importantly, he is in blatant
contradiction, his practices are blatantly inconsequent.

You are truly a piece of work, Mr. Lahn. I am neither lazy nor anti-social
nor do I "sell" my software nor am I disadvantaging anyone else.

You, sir, are a troll, and just barely above VK in the amount of value that
you add to this newsgroup. If the word "anti-social" describes anyone here,
it would be you. Maybe you don't interact with humans in the real world, but
if you behave in real life as you do here, I don't imagine that many people
would find your company welcome. You are judgemental, insulting, demeaning,
elitist, anal retentive, combative, and unpleasant.


Your judgement and appreciation of Thomas 'Pointed Ears' Lahn definitely
meets my own.

Gérard
--
remove blah to email me
Apr 28 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
19748
by: Markus Ernst | last post by:
Hello Reading the follwing document: http://www.w3.org/TR/WD-positioning-970131#In-flow it seems very clear that position:relative should be relative to the parent element. So in the following...
0
1317
by: fleemo17 | last post by:
IE5 (5.2.3) for the Mac seems to be having problems displaying page elements using Position attributes. If I place the position of my form box (shown at http://tinyurl.com/cz5xd ) using "absolute,"...
8
2119
by: ed | last post by:
Does anyone know if ASP.NET 2.0 is going to incorporate "maintain scroll position on postback" in non-IE browsers like Firefox? This seems like an often requested feature on these newsgroups...
10
54842
by: InvisibleMan | last post by:
Hi, Thanks for any help in advance... Okay, I have the JS listed below that calls for the display of the (DIV) tag... cookie function not included, as don't feel its necessary but you'll get the...
2
2587
by: yawnmoth | last post by:
As I understand it, document.layers only works in Netscape 4+ (ie. it doesn't work in any version of Internet Explorer), while document.all only works in Internet Explorer 4+ (ie. it doesn't work...
2
2387
by: Eric Lindsay | last post by:
I have been trying to do a CSS liquid layout imitating a frame, using position: fixed for header, footer, and side navigation, and a fixed background image. Page is valid HTML 4.01 Strict, and is...
2
1959
by: petermichaux | last post by:
Hi, It seems like determining element position in a web page is a difficult task. In the position reporting source code I've looked at there are special fixes for at least some versions of...
2
9748
by: Eric Lindsay | last post by:
Googling suggests that IE7 may support position: fixed; I think this might be handy for some pages I want to do. Does anyone have any comments about whether fixed should be considered for use on...
3
2203
by: Avaenuha | last post by:
I have a banner-and-sidebar menu that I want to remain always-accessible. So I've made them both position:fixed, and used z-index to ensure the layers work properly. Both the CSS and HTML validate,...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.