473,670 Members | 2,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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<b r>blah<br>blah< br>blah<br>
blah<br>blah<br >blah<br>blah<b r>blah<br>blah< br>blah<br>
<div class="sectionh ead">
<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<b r>blah<br>blah< br>blah<br>
</div>
blah<br>blah<br >blah<br>blah<b r>blah<br>blah< br>blah<br>blah <br>
blah<br>blah<br >blah<br>blah<b r>blah<br>blah< br>blah<br>blah <br>
blah<br>blah<br >blah<br>blah<b r>blah<br>blah< br>blah<br>blah <br>
blah<br>blah<br >blah<br>blah<b r>blah<br>blah< br>blah<br>blah <br>
</html>

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

Stan

Jan 14 '07 #1
5 1817
ASM
st**@capitalcit yrealty.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="setTim eout('self.loca tion=\'#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:1 50px; border:1px solid red">
some text
</p>
<h2 id="test"place to reach</h2>
<p style="height:1 50px; 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**@capitalcit yrealty.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="setTim eout('self.loca tion=\'#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:1 50px; border:1px solid red">
some text
</p>
<h2 id="test"place to reach</h2>
<p style="height:1 50px; 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**@capitalcit yrealty.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.pageYOff set? window.pageYOff set : document.body.s crollTop;
setTimeout('scr ollTo(0,'+posy+ ')',0);
}
</script>

<a href="#test" onclick="rePlac e()">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**@capitalcit yrealty.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.pageYOff set? window.pageYOff set : document.body.s crollTop;
setTimeout('scr ollTo(0,'+posy+ ')',0);
}
</script>

<a href="#test" onclick="rePlac e()">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**@capitalcit yrealty.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
5396
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 attempting to do this by using an anchor point name of an anchor located
1
16682
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 (!document.getElementById) return; obj=document.getElementById("thetext"); pos -=1; if (pos < 0-obj.offsetHeight+130) return;
4
6942
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 and would like to use little arrows that people could press to see more of the text rather than have a very long page.... How should I go about that? I use DW3. Can it be done???? Thanks for any info!! ;-)
1
7022
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 very little information to display, thus the frame has no scrolling bars, but on those where there is lots then the vertical scrolling bar appears. However, on two of my pages the horizontal scrolling bar has appeared also - why!? I'm just...
44
919
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 put either tag inside an HTML <TD> and have the same kind of scrolling effect. This would allow me to fill the screen and have the size of the scrolling box change on resize. Thanks in advance.
2
3827
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# Windows MDI Application, as in MSDN, ie : 1) Create Windows Application (Form1), set IsMDIContainer to true 2) Create MainMenu component in the form, with top level '&File', submenu '&New' and '&Close', and another top level '&Window' with MDIList...
0
2240
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 rich textbox to the tab sheet. The rich textbox is placed at 0,0 (upper left corner) within the tab sheet and is initially 1 "line" tall to accomodate the user's first line of text. The rich text box is, in actuality, a user control of mine...
0
1614
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 restrict the vertical scrolling in this situation (when an internal link is clicked) to the space within the div (the entire page should not scroll). Is this possible?
0
8466
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8896
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8810
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8590
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7410
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4387
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2798
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2035
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.