script for Centering layer - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

script for Centering layer

Can we write a script so that the layer inserted in a web page changes its left and top position according to resolution of monitor like the left position of the layer should take exactly the mid position of the monitor so in case a user visit the page with monitor resolution of 640 the left position of the layer should be 320 and if some other user will visit the same page from 1024 resolution then the layer should slide its left position to 512

Comments

  • : Can we write a script so that the layer inserted in a web page changes its left and top position according to resolution of monitor like the left position of the layer should take exactly the mid position of the monitor so in case a user visit the page with monitor resolution of 640 the left position of the layer should be 320 and if some other user will visit the same page from 1024 resolution then the layer should slide its left position to 512
    :

    for Internet explorer:
    scrnwidth=window.document.body.offsetWidth;
    scrnheight=screen.height;
    Layerhight=100;
    Layerwidth=100;
    layername.style.left=scrnwidth/2-Layerwidth/2;
    layername.style.top=scrnheight/2-Layerheight/2;

    for Netscape:
    scrnwidth=window.innerWidth;
    scrnheight=window.innerHeight;
    Layerhight=100;
    Layerwidth=100;
    window.document.layername.left=scrnwidth/2-Layerwidth/2;
    window.document.layername.top=scrnheight/2-Layerheight/2;


    URL:http://www.uaweiss.de

Sign In or Register to comment.