Zend - The PHP Company




HTML

Add Code


Object position  

Type: code fragment
Added by: ghost
Entered: 11/11/2000
Last modified: 01/12/2000
Rating: - (fewer than 3 votes)
Views: 5619
Position any object exactly where you want it on your web page, using layers. This snippet works with both NS and IE. Released into the PD as a Mailware - please mail and tell if you use!


<?php
// You are allowed to use this software for ANY purpose,
// if you send me a mail, telling me that you use it.
// info@w10.net

// Position anything between ObjPos(x,y) and OE()
// at any position on your web page.
// X = Position in pixels from left.
// Y = Position in pixels from top.
// Layername = The name of the new layer.
function ObjPos($x=0,$y=0,$layername="n1")
{
    if (
Browser() == "NS")
    { echo 
"<layer id='$layername' left='$x' top='$y'>" ; return ; } else
    { echo 
"<div STYLE='position:absolute; left:$x; top:$y'>" ;  return ; }
}    

// Terminate positioning..
function OE() 
{
    if (
Browser() == "NS"
    { 
        echo 
"</layer>" ;  
        return ;
    } 
    echo 
"</div>" ;  
}    

// Find out which browser the remote user has.
function Browser()
{
    global 
$HTTP_USER_AGENT ;
    
$Browser_Name strtok($HTTP_USER_AGENT"/");
        
    if(
ereg("MSIE"$HTTP_USER_AGENT)) return("IE") ; 
    if(
ereg("Opera"$HTTP_USER_AGENT)) return("IE") ; 
    if(
ereg("Netscape6"$HTTP_USER_AGENT)) return("IE") ; 
    
    if(
$Browser_Name == "Mozilla") return("NS") ; 
}

?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories