Solved

Page scroll when using document.body.scrollTop

Posted on 2003-10-31
5
517 Views
Last Modified: 2010-08-05
Please check www.VisionSimulations.com. I want to show a full size image when the user clicks a thumbnail on the right. I want to show the image in the middle of the viewport, so I need to find out if the page is scrolled. Scroll down to the bottom of www.VisionSimulations.com and then click an image. You'll see that the page scrolls back to the top. It's as if positioning the ShowImagesDiv causes the page to scroll back. Below is the javascript.

Why does this happen and how can I prevent it?

Roger

function ShowImage(stPicture, iWidth, iHeight)
  {
  stPicture="url(" + stPicture + ")" ;
  iLeft = document.body.clientWidth/2-iWidth/2;
  document.getElementById("ShowImagesDIV").style.left=iLeft ;
  //document.getElementById("ShowImagesDIV").style.top=document.body.scrollTop + document.body.clientHeight/2 - iHeight/2;
  document.getElementById("ShowImagesDIV").style.top=document.body.scrollTop;
  document.getElementById("ShowImagesDIV").style.width=iWidth;
  document.getElementById("ShowImagesDIV").style.height=iHeight;
  document.getElementById("ShowImagesDIV").style.background=stPicture;
  document.getElementById("ShowImagesDIV").style.visibility="visible" ;
  return false;
  }
0
Comment
Question by:rdavis101
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:NetGroove
ID: 9659296
I remember this question with the same site.
The solution was the ";retern false" suffix.

Did you ask this question before?

0
 
LVL 10

Accepted Solution

by:
NetGroove earned 125 total points
ID: 9659320
I found your question:
http://oldlook.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20733806.html

Could it be you are catching hits here?
Or do you remember Alsheimer?

0
 

Author Comment

by:rdavis101
ID: 9659365
You guys have a better memory than I do. Thanks.
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9659392
Oh, then please take my apologize for bad assumptions :)

Thanks for the points (in spite of my typo!)

See you,
NetGroove

0
 

Author Comment

by:rdavis101
ID: 9659407
Oops...I accepted the answer and just assumed I'd made a stupid mistake. But, that doesn't seem to be the case, since return false; is in the code.

So what's the deal?

Roger
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Not allowed to load local recource. 4 35
How to format numbers and letters in nested lists 5 34
Json Schema 8 32
Asp in server side with Mssql Server 7 4 29
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

821 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