Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-30-2006, 11:02 PM   PM User | #1
Gretchen
New to the CF scene

 
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Gretchen is an unknown quantity at this point
JS Layer Position Problem on Click

I have a form divided into virtual layers that are alternately visible and hidden. I move between layers using buttons according to the following code:

<input type="button" id="B1" value="Go Back" onClick="showLayer('page2')">
<input type="button" id="C2" value="Continue" onClick="showLayer('page3')">

When I click either button, it moves me to the correct layer, but always to the same position on the page as the cursor was last. In other words, if I was 550px down the page when I clicked "Continue," the next layer opens at 550px down the screen. As the content of some layers is only a few px high, you have to scroll up to see the content. This is fine for me as I know there is something on the page, but for a visitor to the form, they will think they clicked through to a blank page and shut down.

How do I get it to open at the top of the next layer?

The layers are created by <div> tags with "page" style defined by css as follows:

.page{
position: absolute;
top: 10;
left: 100;
visibility: hidden;

I tried adding hyperlinks (#name) between the buttons and the top of each page, but this has no effect.

Any ideas?!
Gretchen is offline   Reply With Quote
Old 12-30-2006, 11:58 PM   PM User | #2
MichaelCL
New to the CF scene

 
Join Date: Dec 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
MichaelCL is an unknown quantity at this point
maybe you can use display: 'none' or 'block' instead. I don't recognise the symptoms you're talking about but in my experience the visibility property doesn't affect the layout, leaving large blank spaces...
MichaelCL is offline   Reply With Quote
Old 12-31-2006, 01:27 AM   PM User | #3
Gretchen
New to the CF scene

 
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Gretchen is an unknown quantity at this point
Hmmm...

I tried using display: 'none' and 'block.' Neither solves the problem. I am wondering if this script has any bearing:

Code:
<script type="text/javascript">
function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length)
{
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
Gretchen is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:07 AM.


Advertisement
Log in to turn off these ads.