473,324 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

scrolling within div

This is a follow-up to an earlier posting - this time with sample code.

In the code below, the jump within the div causes movement within the
div and as well withing the page as a whole. I am looking for a way to
restrict movement, triggered by the jump, to the area within the div
only.

Here is the code.

<html>
<head>
<style type="text/css">
..sectionhead {
text-align: left;
background: #EBEBEB;
height: 7.25em;
width: 100%;
border-style:ridge;
border-width:thin;
border-color:grey;
float: left;
margin-left:0px;
margin-right:0px;
overflow-y: auto;
color: black;
}

</style>
</head>
<body>
blah<br>blah<br>blah<br>blah<br>blah<br>blah<br>bl ah<br>
blah<br>blah<br>blah<br>blah<br>blah<br>blah<br>bl ah<br>
<div class="sectionhead">
<a href="#test">go to "test"</a><br>
text in div<br>text in div<br>text in div<br>text in div<br>
<a name="test"></a>
more text in div<br>more text in div<br>more text in div<br>
more text in div<br>more text in div<br>more text in div<br>
blah<br>blah<br>blah<br>blah<br>blah<br>blah<br>bl ah<br>
</div>
blah<br>blah<br>blah<br>blah<br>blah<br>blah<br>bl ah<br>blah<br>
blah<br>blah<br>blah<br>blah<br>blah<br>blah<br>bl ah<br>blah<br>
blah<br>blah<br>blah<br>blah<br>blah<br>blah<br>bl ah<br>blah<br>
blah<br>blah<br>blah<br>blah<br>blah<br>blah<br>bl ah<br>blah<br>
</html>

------------

Stan

Jan 14 '07 #1
5 1799
ASM
st**@capitalcityrealty.ca a écrit :
This is a follow-up to an earlier posting - this time with sample code.

In the code below, the jump within the div causes movement within the
div and as well withing the page as a whole. I am looking for a way to
restrict movement, triggered by the jump, to the area within the div
only.
Do not understand ... and if 'test' is outside of viewport ?
You have to scroll the page before to reach it, no ?

<html>
<head>
<body id="cap">
<a href="#test" onclick="setTimeout('self.location=\'#cap\'',0);">
reach test
</a>
<div style="height: 400px; border:1px solid blue">
filling up
</div>
<div style="height: 6em; overflow: auto">
<p style="height:150px; border:1px solid red">
some text
</p>
<h2 id="test"place to reach</h2>
<p style="height:150px; border:1px solid red">
some more text
</p>
</div>
<div style="height: 400px; border:1px solid blue">
filling up
</div>
</body>
</html>

Works with my FF, Safari, Opera

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 14 '07 #2
Thanks for your reply, but in the test example I provided, both the
"from" and the
"to" are within the div.

To be clear, I am looking at a situation where:

1) both the "from" and the "to" are within the div
2) there is enough content on the page istelf to require page scrolling
Note: In the code provided there is enough content provided to require
page scrolling on a 17" screen at 1024 X 768.

Stan

ASM wrote:
st**@capitalcityrealty.ca a écrit :
This is a follow-up to an earlier posting - this time with sample code.

In the code below, the jump within the div causes movement within the
div and as well withing the page as a whole. I am looking for a way to
restrict movement, triggered by the jump, to the area within the div
only.

Do not understand ... and if 'test' is outside of viewport ?
You have to scroll the page before to reach it, no ?

<html>
<head>
<body id="cap">
<a href="#test" onclick="setTimeout('self.location=\'#cap\'',0);">
reach test
</a>
<div style="height: 400px; border:1px solid blue">
filling up
</div>
<div style="height: 6em; overflow: auto">
<p style="height:150px; border:1px solid red">
some text
</p>
<h2 id="test"place to reach</h2>
<p style="height:150px; border:1px solid red">
some more text
</p>
</div>
<div style="height: 400px; border:1px solid blue">
filling up
</div>
</body>
</html>

Works with my FF, Safari, Opera

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 14 '07 #3
ASM
st**@capitalcityrealty.ca a écrit :
Thanks for your reply, but in the test example I provided, both the
"from" and the
"to" are within the div.

To be clear, I am looking at a situation where:

1) both the "from" and the "to" are within the div
Not a problem
2) there is enough content on the page istelf to require page scrolling
Yeap
Note: In the code provided there is enough content provided to require
page scrolling on a 17" screen at 1024 X 768.
That's right, and ?
Perhaps could you try to see if page was scrolled before to jump
then after the jump re-scroll it to its previous position ?

<script type="text/javascript">
function rePlace() {
var posy = window.pageYOffset? window.pageYOffset : document.body.scrollTop;
setTimeout('scrollTo(0,'+posy+')',0);
}
</script>

<a href="#test" onclick="rePlace()">go to "test"</a>

In your CSS, as overflow-y:auto; isn't recognize in all browsers
prefer overflow: auto;
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 15 '07 #4
Thanks for the suggestion. I tried it but it is quite a jerky
operation, scrolling one way and then back again. It woulld be nice to
find a better way if possible.
ASM wrote:
st**@capitalcityrealty.ca a écrit :
Thanks for your reply, but in the test example I provided, both the
"from" and the
"to" are within the div.

To be clear, I am looking at a situation where:

1) both the "from" and the "to" are within the div

Not a problem
2) there is enough content on the page istelf to require page scrolling

Yeap
Note: In the code provided there is enough content provided to require
page scrolling on a 17" screen at 1024 X 768.

That's right, and ?
Perhaps could you try to see if page was scrolled before to jump
then after the jump re-scroll it to its previous position ?

<script type="text/javascript">
function rePlace() {
var posy = window.pageYOffset? window.pageYOffset : document.body.scrollTop;
setTimeout('scrollTo(0,'+posy+')',0);
}
</script>

<a href="#test" onclick="rePlace()">go to "test"</a>

In your CSS, as overflow-y:auto; isn't recognize in all browsers
prefer overflow: auto;
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 15 '07 #5
ASM
st**@capitalcityrealty.ca a écrit :
Thanks for the suggestion. I tried it but it is quite a jerky
operation, scrolling one way and then back again. It woulld be nice to
find a better way if possible.
It is quite the same feature as given previously.

Other way could be to scroll the overflow, if you know exactly how much
pixels to slide down.
Personally I can't calculate this, because user can ask to its browser
to display text bigger than original size.
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 15 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: yootzee | last post by:
Greetings all, I'm having a problem with scrolling vertically in a newly created browser window. The vertical scrolling is to reach some anchor point within the new browser window. I'm...
1
by: Midas NDT Sales | last post by:
I have been looking at a simple example of a scrolling text box (the one in the SAM book) as below: <script language="JavaScript"> var pos=100; function Scroll() { if...
4
by: Cat Laugel | last post by:
Hello, I am redesigning my website and would like to have the text scroll within the webpage without the page itself scrolling.... if you understand what I mean... ;-) I want a very sleek look...
1
by: Kirk | last post by:
Is it possible to stop horizontal scrolling whilst still maintaining vertical scrolling within an <IFRAME> ? Within each page of my site I have an IFRAME for content. For some pages there is...
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
2
by: James CC | last post by:
I have a strange bug in C# using windows forms. To make sure it's not some bug with my code, I've gone back to a simple test app, and still see the same behavior. I have created a simple C#...
0
by: 23s | last post by:
Is there any way I can send a vertical value to a form's scroll position? I have a full-screen form that, at launch, contains an empty tab sheet. At run time, the user can dynamically append a...
0
by: stan | last post by:
I have internal links/jumps within divs. The divs have vertical scrolling. When a link is clicked, both the space within the div as well as the entire page vertically scroll. I would like to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.