?
Solved

DHTML: how do I center layers ?

Posted on 1998-09-23
6
Medium Priority
?
200 Views
Last Modified: 2010-04-09
Is it possible to center a layer relative to the 'document' width ?
0
Comment
Question by:aloha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
jbirk earned 300 total points
ID: 1838045
Using this seems to work for both netscape and ie:
<DIV ID="hw2Image" align="center" style="position:absolute;top:80px;visibility:hidden;border-width:thin;align:center;">

using align="center" does it only for IE and align:center; in the style does it only for netscape.

Hope this works for you!
-Josh
0
 

Author Comment

by:aloha
ID: 1838046
It seems to work fine with IE4. But with NS4 if you resize the browser window you have to reload the page to center it again becuase for some strange reason after the resize the layer aligns itself to the left!

Any solution for this problem ?
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1838047
It seems that you have found a rather strange and bad error in netscape.  I tried a few things and couldn't get it to work.  So the only solution I could come up with was to reload the page onresize.  The code would look like this:
onResize="if (!document.all) document.go(0);"
That goes in the body tag.
It will work fine, but if you change the layers or have forms, it may reset that which is undesirable.  Test it to see, if it does screw up the page I'll check to see if there's some other way.

-Josh
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Expert Comment

by:jbirk
ID: 1838048
Man I don't know what came over me.  This line:
onResize="if (!document.all) document.go(0);"
should be:
onResize="if (!document.all) history.go(0);"

Sorry about that.
-Josh
0
 

Author Comment

by:aloha
ID: 1838049
It works, Josh.

Do you think there could be a solution using Javascript ? Instead of reloading the page the onresize event could call a function that would update the left value of the Layer based on the browser width. I think that this might work, but I don't know much of Javascript. Could you help me here ?


0
 
LVL 8

Expert Comment

by:jbirk
ID: 1838050
Well... yeah, you could do this.  It might be somewhat more complex though.  Ask a question in the JavaScript area, and I or someone else will help you there.
BTW, technically, it is already using javascript.  The onResize command is a javascript event, and what it does is execute the javascript event handler supplied to it as an argument, so:
"if (!document.all) history.go(0);"
is the event handler I gave it which simply said to reload the document when the onResize event occured.

So, ask a question in JavaScript (50 points is probably efficient for this), and someone will assist you (I'm not sure if I have the time right now, so it may be someone else).

Good luck, and glad I was able to help!
-Josh
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question