Solved

Page scroll when using document.body.scrollTop

Posted on 2003-10-31
5
518 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
[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
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

739 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