Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can javascript centralise the web page?

Status
Not open for further replies.

obliex

IS-IT--Management
Jul 24, 2003
28
SG
Hi,

Can anyone advise me whether can use javascript to centralise the webpage. That is no matter what the user's Pc desktop resolution is, the webpage created will automatically be in the centre of the browser.

Please advise.

Thank you in advance.
 
<table align="center">

will do the job...

Known is handfull, Unknown is worldfull
 
I am using layer in my webpages,the above code cannot be apply. another other methods? thank you.
 
<script>
ScreenWidth=screen.width
LayerWidth=document.getElementById("Layerid").offsetWidth
Diff=ScreenWidth-LayerWidth
Margin=Diff/2
LayerLeft=parseInt(document.getElementById("Layerid").style.left.replace(/[^\d]/g,""))
LayerLeft+=Margin
document.getElementById("Layerid").style.left=LayerLeft+"px"
</script>

Known is handfull, Unknown is worldfull
 
Thank you for your reply. I am sorry. I am very new in javascript. I have tried the script. It does not work. is there anything that I need to change?
 
wow, that simply increases the scope:
1. give the layer that u want to center the id="Layerid"
2. insert the <script> tag at the end of the page...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top