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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.