?
Solved

Cross browser problem - Relative position of layer triggered by mouseover

Posted on 2005-03-22
7
Medium Priority
?
267 Views
Last Modified: 2006-11-17
Hello,

i have a problem with the position of the layer "myLayer", triggered by several links. Everything works fine in IE, but in Mozilla, the position of the triggered layer is about 50 Pixels above the intendended position. I need relative position in this layout. I know, that i wont have the problem with absolute positioning. Can you show me a way how to be sure that in both browsers (IE and Moz) the layer will be in the same position.

Thanks for your help

Chilli


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Unbenanntes Dokument</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<script type="text/javascript">
function show(object,val) {
document.getElementById(object).style.visibility = val;
}
</script>
</head>

<body background="images/hg.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<br>
<table width="779" border="0" align="center" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="167" height="85" valign="top" background="images/logo_links.gif"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td width="337" valign="top" background="images/logo_mitte.gif"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td width="275" valign="top" background="images/logo_rechts.gif"><a href="#">test</a></td>
  </tr>
  <tr>
    <td height="478" valign="top" background="images/links.gif"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td valign="top"><img src="images/mitte.gif" width="337" height="478" border="0" usemap="#Map"></td>
    <td valign="bottom" background="images/rechts.gif"><a href="#" onMouseOver="show('myLayer','visible')" onMouseOut="show('myLayer','hidden')">hahha</a></td>
  </tr>
</table>
<table width="779" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="1"><div id="Layer1" style="position:relative; width:200; height:115; z-index:1; left: 440; top: -501;"><img src="images/geld.gif" width="317" height="164"></div>
      <div id="myLayer" style="position:relative; width:113; height:68; z-index:2; left: 296; top: -680; visibility: hidden;"><img src="images/hamburg.gif" width="113" height="68"></div></td>
  </tr>
</table>
<map name="Map">
  <area shape="circle" coords="161,44,19" href="#" onMouseOver="show('myLayer','visible')" onMouseOut="show('myLayer','hidden')">
</map>


</body>
</html>
0
Comment
Question by:Chillipowder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13599868
You can start by changing this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

To this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 

So that you get both of them renderin gins standards compliant mode.  Then at least they will be following the same rendering rules, and we will be abel to get it closer.

Cd&
0
 

Author Comment

by:Chillipowder
ID: 13600091
Hello Coboldinosaur,

i changed it, but now i get in even more trouble with the layout. If i leave the layers in the second table, i cant set their position, so that they float above the first table When i put the layers into the first table, the table extends across the borders and the layout gets destructed.

Greetings
 
chilli
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13600305
Well what you are seeing is a small sample of what a lot of users are going to see.  With table based layouts even small differences in browsers, platform, os and user preferences can result in radical changes.  

You really should be developing the layers as independent components that can be manipulated inedependently, and directly.  

If you want to do it this way.  Setup for IE.  Then change the valuess until it looks right in Mozilla.  Then just add scriping to do browser detectiona nad dynamically positon from the onload even.

Of course that will only give you two exact setups, but it should be close in sme of the others.  Of course you might have to make changes to support new releases as they come out.

No matter what you do a lot of users are going to get broken pages, but that is not uncommon with Dreamweaver style templates and table based layout.

BTW,

The screwed up ayout is the correct rendering for that layout.  The browser is just doing what yo told it to do applying standards compliant rules.  You should be working from that to get where you want to go so that you reduce down stream maintannce costs.

Cd&


Cd&
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 10

Assisted Solution

by:slamhound
slamhound earned 105 total points
ID: 13608468
As well as detecting the browser and using JavaScript to set the position based on which browser is being used, you can use JS to set the position of the layer. This is done by assinging values to obj.pixelTop and obj.pixelLeft. You can do some caluclations on how the screen is layed out and then set the position of the layer. eg. get the width of the screen, divide by 2 and youv'e got a centre place to start with.

Hope this helps!
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13609586
Do not use pixelLeft and pixelTop.  They are IE only.  References should to position should use offsetLeft and offsetTop; or reference the prperties directly in the style with parseInt(obj.style.left) and parseInt(obj.style.top)

Cd&
0
 

Author Comment

by:Chillipowder
ID: 13610576
@slamhound, coboldinosaur

after the second comment by Cobol i decided to throw the tables away and begin to layout the page only in layers. Both of your comments pointed out, that i shouldnt use pixeltop and pixelleft. Did you mean the position of the layers like in

<div id="myLayer" style="position:relative; width:113; height:68; z-index:2; left: 296; top: -680; visibility: hidden;"><img src="images/hamburg.gif" width="113" height="68"></div>

what would be the appropriate code with parseInt(obj.style.left)??

Do i have to use js to position the layer? Wont it work with css / dhtml alone?

Chilli
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 645 total points
ID: 13610679
The pixel left an parseInt stuff were just scripting references.  if you are going to go to straight layers, you don't need tham you can do your positiong with CSS directly.

These will help you understand how to do it easily:

http://www.w3.org/2002/03/csslayout-howto

http://www.w3schools.com/css/css_positioning.asp

Cd&


0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question