[thelist] Tip: X-browsers layers
Matt Biscay
mbiscay at skyminds.net
Mon Dec 3 11:12:50 CST 2001
Hi Evolters,
Until recently, my site wouldn't display its layers correctly under
Netscape/Mozilla and the result in IE was slightly different from Opera (my
favorite browser). The trouble is that I did not want to use Javascript but
mere PHP.
Here is the tip to use layers with the majority of browsers:
- for IE: use the <div> tag.
- for Opera, the <div> tag also works. Yet, you have to tweak the values and
adjust them manually
- for Netscape < 5.0 (N4.7X), use the <layer> tag.
- for Netscape > 5.0 (N6.0), use the <span> tag.
Here is what I did:
1) Get browser name
$Browser_Name = strtok($HTTP_USER_AGENT, "/");
$Browser_Version = strtok(" ");
2) Define browsers
//IE
if(ereg("MSIE", $HTTP_USER_AGENT))
{
$Browser_Name = "MSIE";
$Browser_Version = strtok("MSIE");
$Browser_Version = strtok(" ");
$Browser_Version = strtok(";");
}
// other browsers
3) use the right layer with the right browser:
if ($Browser_Name=="MSIE")
{
<div id="ie_layer" style="position:absolute; left:10px; top:85px;
width:745px; height:158px; z-index:1">
}
elseif ($Browser_Name=="Mozilla" & $Browser_Version < 5.0)
{
<layer id="nn4_layer" left="5" top="100" width="124" height="158"
z-index="2">
}
elseif ($Browser_Name=="Mozilla" & $Browser_Version >= 5.0)
{
<span id="nn6_layer" style="position:absolute; left:5px; top:100px;
width:124px; height:158px; z-index:2">
}
That's it ! Hope it will help some of you.
It works fine on http://www.skyminds.net/
-----
Matt Biscay
mbiscay at skyminds.net
|--------------------------------------
| http://www.skyminds.net/
|--------------------------------------
More information about the thelist
mailing list