Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

Cross browser problem - Relative position of layer triggered by mouseover

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
Chillipowder
Asked:
Chillipowder
  • 4
  • 2
2 Solutions
 
COBOLdinosaurCommented:
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
 
ChillipowderAuthor Commented:
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
 
COBOLdinosaurCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
slamhoundCommented:
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
 
COBOLdinosaurCommented:
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
 
ChillipowderAuthor Commented:
@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
 
COBOLdinosaurCommented:
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

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now