I am trying to use scrollIntoView to programatically scroll an area on
one of my pages.
It wors just like you would expect it to when the page itself doesn't
have any scrolling (the page is smaller than the browser window).
However, as soon as you introduce the same code on a page that has a
vertical scrollbar, the scrollIntoView causes not only the scroll area
to move, but also the entire form.
Is this by design, or is there a workaround?
To see what I am talking about just run this code. It will cause the
table to "jump" to the top of the page along with causing the selected
row to jump to the top of the scroll area.
<html>
<script>
function scrollTable()
{
var rowVal = txtRowNo.value;
var strId = "tr" + rowVal;
var objTR = document.getEle mentById(strId) ;
if(objTR)
objTR.scrollInt oView(true);
else
{
objTR = document.getEle mentById("tr1") ;
objTR.scrollInt oView(true);
}
}
</script>
<BODY>
<BR><BR>a<BR><B R>a<BR><BR>a<BR ><BR>a<BR><BR>a <BR><BR>a<BR><B R>a<BR><BR>a<BR ><BR>a<BR><BR>a <BR><BR>a<BR><B R>a<BR><BR>a<BR ><BR>a<BR><BR>a <BR><BR>a<BR><B R>a<BR><BR>a<BR ><BR>a<BR><BR>a <BR><BR>a<BR><B R>a<BR><BR>a<BR ><BR>a<BR><BR>a <BR><BR>a<BR><B R>a<BR><BR>a
enter a number:<input type="text" id="txtRowNo">
<input type=button onclick=scrollT able() value="Click me">
<div style="height:1 00px;overflow:a uto;border:1px solid black">
<table width="100%" border="1">
<tr id="tr1"><td>1 </td><td>Row 1</td></tr>
<tr id="tr2"><td>2 </td><td>Row 2</td></tr>
<tr id="tr3"><td>3 </td><td>Row 3</td></tr>
<tr id="tr4"><td>4 </td><td>Row 4</td></tr>
<tr id="tr5"><td>5 </td><td>Row 5</td></tr>
<tr id="tr6"><td>6 </td><td>Row 6</td></tr>
<tr id="tr7"><td>7 </td><td>Row 7</td></tr>
<tr id="tr8"><td>8 </td><td>Row 8</td></tr>
<tr id="tr9"><td>9 </td><td>Row 9</td></tr>
<tr id="tr10"><td>1 0</td><td>Row 10</td></tr>
<tr id="tr11"><td>1 1</td><td>Row 11</td></tr>
<tr id="tr12"><td>1 2</td><td>Row 12</td></tr>
<tr id="tr13"><td>1 3</td><td>Row 13</td></tr>
<tr id="tr14"><td>1 4</td><td>Row 14</td></tr>
<tr id="tr15"><td>1 5</td><td>Row 15</td></tr>
<tr id="tr16"><td>1 6</td><td>Row 16</td></tr>
</table>
</div>
<BR><BR>a<BR><B R>a<BR><BR>a<BR ><BR>a<BR><BR>a <BR><BR>a<BR><B R>a<BR><BR>a<BR ><BR>a<BR><BR>a <BR><BR>a<BR><B R>a<BR><BR>a<BR ><BR>a<BR><BR>a <BR><BR>a<BR><B R>a<BR><BR>a<BR ><BR>a<BR><BR>a <BR><BR>a<BR><B R>a
</body>
</html> 3 7912
cmay wrote: I am trying to use scrollIntoView to programatically scroll an area on one of my pages.
It wors just like you would expect it to when the page itself doesn't have any scrolling (the page is smaller than the browser window).
However, as soon as you introduce the same code on a page that has a vertical scrollbar, the scrollIntoView causes not only the scroll area to move, but also the entire form.
Is this by design, or is there a workaround?
try :
function scrollTable(yes No)
{
var rowVal = document.getEle mentById('txtRo wNo').value;
var strId = "tr" + rowVal;
var objTR = document.getEle mentById(strId) ;
if(objTR)
objTR.scrollInt oView(yesNo);
else {
objTR = document.getEle mentById("tr1") ;
objTR.scrollInt oView(yesNo);
}
}
and your button ->
<input type=button onclick=scrollT able(true) value="All Scroll To">
<input type=button onclick=scrollT able(false) value="Scroll To Row">
As you'll see a choice is possible
--
Stephane Moriaux et son [moins] vieux Mac
It looks like all you did was make change the parameter passed into the
scrollIntoView method.
When this is true it makes the scrollable area jump to the top of the
page, when this is false it makes it jump to the bottom of the page.
If that is the choice you are talking about it doesn't really help. I
don't want the page to jump, I just want the scrollable div to move,
not the entire page.
Am I missing something?
Bump.
Anyone out there with knowledge on this issue? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andres Mas Torrecillas |
last post by:
Hi!
I'm having a little trouble with an IFRAME added in an HTML page. IFRAME has
a fixed size and it contains another HTML page, which only has some text
paragraphs and a pair of images aligned left and right (with 'style="float:
{left | right}"'). There's no tables or anything with a fixed size.
Problem is that in browsers like Opera 7, the IFRAME shows perfectly and
just vertical scroll bar is showed (that's what I want). But on...
|
by: Steve Murphy |
last post by:
Do .scrollIntoView, .focus, and .select work in Safari, or am I just doing
something wrong.
The following code works in Firefox, Netscape, and IE on both Mac and
Windows, but fails on Safari:
tempobj = this.elements;
tempobj.scrollIntoView();
tempobj.focus();
tempobj.select();
|
by: Larry Brown |
last post by:
Hi,
I'm working on an ASP.NET 2 application, with framework 2.0 beta. I have a
classic form, with a listbox. This field is in autopostback=true. When I
change the selected value, the page is reloaded, and the scrollIntoView
function is called at reload. It is called in the Webform_Autofocus(focusId)
function, whose call is included by ASP.NET at page generation. Here is the
code of this function:
function WebForm_AutoFocus(focusId) {...
|
by: xevi.matavacas |
last post by:
Hi friends,
I found a problem while "scrolling into view" and to overcome this I
made a function to simulate javascript's function. I would like to
share it and here it is:
function alternativeScrollIntoView(parentDiv,elementIntoDiv)
{
var principal =parentDiv;
principal.scrollTop = 0;
|
by: Keith |
last post by:
I have a web form that contains a repeater control that is designed to ask
like a check book register. Clicking on a certain transaction takes the user
to a different .aspx page where it can be edited and then saved. Currently,
after saving the edited transaction and returning to the check register, the
repeater control table returns to the bottom. I would like the edited
transaction to appear in the table instead. I know that a...
| |
by: Keith |
last post by:
I have a web form that contains a repeater control that is designed to ask
like a check book register. Clicking on a certain transaction takes the user
to a different .aspx page where it can be edited and then saved. Currently,
after saving the edited transaction and returning to the check register, the
repeater control table returns to the bottom. I would like the edited
transaction to appear in the table instead. I know that a JavaScript...
|
by: Alex Calder |
last post by:
How's that for a subject line? :)
OK, here's the deal.
I have a web page that features a Flash movie about halfway down the
page, and inside that Flash movie is content that typically exceeds
the height of the movie, and accordingly, scrolls via use of a scroll
bar.
I've been testing out this page on friends, and the common complaint
|
by: sylver |
last post by:
Hi to all,
I found out the you can use the scrollIntoView() method, to scroll an
element (ie: a <divwith lots of content that it overflows) to its
bottom / last line. But this only happens in IE. Does mozilla have any
methods that do the same? Or is there any hacks algo we can try to
perform this for Mozilla?
ref:
http://msdn2.microsoft.com/en-us/library/ms536730.aspx
|
by: knkk |
last post by:
I have an iframe within a page, and i want a div in that frame to scroll to the top of just that frame when a link is clicked upon (so only the page in that frame should scroll up/down, and not the mother page containing the iframe). However, document.all.divID.scrollIntoView() is scrolling the entire page in the window to the top so as to put the div at the top, and not just the page in the iframe.
So first the page in the iframe scrolls...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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...
|
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |