?
Solved

DHTML: how do I center layers ?

Posted on 1998-09-23
6
Medium Priority
?
207 Views
Last Modified: 2010-04-09
Is it possible to center a layer relative to the 'document' width ?
0
Comment
Question by:aloha
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

850 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