473,804 Members | 3,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scrolling Issue

8 New Member
Hello. I created this program that highlights each line of text as the user scrolls up and down using arrow keys. Only problem is when the users scrolls down and up the page scrolls too fast to see the highligted line. Would I have to use a Screen Object to stop this problem. Thanks in advance for your help.
Feb 14 '08 #1
4 1405
acoder
16,027 Recognized Expert Moderator MVP
Show your code or, better still, a link to a test page.
Feb 15 '08 #2
Msleh08
8 New Member
Below is code... Thanks for your help.


[HTML]<HTML>
<Head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>

<style type="text/css">
.tableExample{b order-collapse: collapse; border: 0px solid black;}//code helped by unknown source on codingforums.co m
.tableExample tr td{cursor:point er; border: 0px solid black; padding: 0px;}
.odd{background-color:#F5DEB3'; }
.even{backgroun d-color:#F5DEB3'; }
.high{backgroun d-color:#FFFF00;f ont-size:medium;fon t-weight:bold;pos ition:static;}
.selected{backg round-color:#FFFF00;f ont-size:medium;fon t-weight:bold;}
</style>

<script type="text/javascript">
var table1 = null;
window.onload = function(){
table1 = new table.Selectabl eLSPEC("tableEx ample1",true)
}

var table = {};

table.keys = {
AddNew : function(id,act ion){
this.monitorAct ions[id] = action;
this.quickLooku p.push(id);
},
monitorActions : new Array(),
quickLookup : new Array()
}

table.ActiveTab le = null;

table.Selectabl eLSPEC = function(tableI d,activate){
var ref = this;
this.tableId = tableId;
this._init();
this.selectedId = null;
table.keys.AddN ew(tableId,ref) ;
if(activate){
table.ActiveTab le = tableId;
this.selectFirs t();
}
}

table.Selectabl eLSPEC.prototyp e._init = function(){
var ref = this;
var elemTable = document.getEle mentById(this.t ableId);
var rows = elemTable.getEl ementsByTagName ("tr");
var cnt = rows.length;
for(var i=0; i<cnt;i++){
var className = (i%2)?"odd":"ev en";
rows[i].className = className;
rows[i].defaultClassNa me = className;
rows[i].onmouseover = function(){if(t his.className!= "selected")this .className="hig h";}
rows[i].onmouseout = function(){if(t his.className!= "selected")this .className=this .defaultClassNa me;}
rows[i].onclick = function(){ref. select(this)};
}
elemTable = null;rows=null;
}

table.Selectabl eLSPEC.prototyp e.select = function(elem){
this.removeSlec tions();
this.selectedId = (this.selectedI d!=elem.id)?ele m.id:null;
if(this.selecte dId!=null)elem. className = "selected";

}

table.Selectabl eLSPEC.prototyp e.removeSlectio ns = function(elem){
var elemTable = document.getEle mentById(this.t ableId);
var rows = elemTable.getEl ementsByTagName ("tr");
var cnt = rows.length;
for(var i=0; i<cnt;i++)rows[i].className = rows[i].defaultClassNa me;
elemTable=null; rows=null;
}

table.Selectabl eLSPEC.prototyp e.selectFirst = function(){

var elemTable = document.getEle mentById(this.t ableId);
var firstRow = elemTable.getEl ementsByTagName ("tr")[0];
firstRow.classN ame = "selected"
this.selectedId = firstRow.id;
elemTable=null; firstRow=null;

}

table.Selectabl eLSPEC.prototyp e.keyClick = function(keyCod e){
var direction = (keyCode==38)?-1:(keyCode==40) ?1:0;
if(direction!=0 ){
this.selectNext (direction);
}
}

table.Selectabl eLSPEC.prototyp e.selectNext = function(dir){

var elemTable = document.getEle mentById(this.t ableId);
var rows = elemTable.getEl ementsByTagName ("tr");
var cnt = rows.length;
var hasSelection = false;
for(var i=0; i<cnt;i++){
if(rows[i].className == "selected") {
if((dir==-1 && i>0) || (dir==1 && i+1<cnt)){
rows[i].className = rows[i].defaultClassNa me;
rows[i+dir].className = "selected";
this.selectedId = rows[i+dir].id;
}
hasSelection = true;
break;
}
}

elemTable=null; rows=null;

}



function monitorClick(e) {
var evt = (e)?e:event;

var theElem = (evt.srcElement )?evt.srcElemen t:evt.target;

while(theElem!= null){
if(table.keys.q uickLookup.inde xOf(theElem.id) != -1){
table.ActiveTab le = theElem.id;
return true;
}
theElem = theElem.offsetP arent;
}
table.ActiveTab le = null;
return true;
}


function handleKeyPress( e){
var keycode;
if (window.event) keycode = window.event.ke yCode;
else if (e) keycode = e.which;
if(table.Active Table){
table.keys.moni torActions[table.ActiveTab le].keyClick(keyco de);
}
}

document.onclic k = monitorClick;
document.onkeyd own = handleKeyPress;

</script>
</head>
<body style='backgrou nd-color: #F5DEB3' class='BlackFon t'>
<table class="tableExa mple" id="tableExampl e1">
<tr id="i2_0"><td>. ............... ............... ............... ............... ...........<br> </td></tr>
<tr id="i3_0"><td>. .............He llo World.......Hel lo World......Hell o World.......<br ></td></tr>
<tr id="i4_0"><td>. .............He llo World.......... ............... ............... ........<br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr id="i6_0"><td>" You are today where your thoughts have brought you, and you will be tomorrow where you thoughts take you" by James Allen<br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr id="i8_0"><td>" Nothing limits achievement like small thinking, and nothign expands possibilities like unleashed thinking" by William Arthur Ward<br></td></tr>
<tr id="i9_0"><td>" Work long play hard" UNKNOWN<br></td></tr>
<tr id="i10_0"><td> Javascript is fun<br></td></tr>
<tr id="i11_0"><td> "You are today where your thoughts have brought you, and you will be tomorrow where you thoughts take you" by James Allen<br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr id="i13_0"><td> "Nothing limits achievement like small thinking, and nothign expands possibilities like unleashed thinking" by William Arthur Ward<br></td></tr>
<tr id="i14_0"><td> "Nothing limits achievement like small thinking, and nothign expands possibilities like unleashed thinking" by William Arthur Ward<br></td></tr>
<tr id="i15_0"><td> "Nothing limits achievement like small thinking, and nothign expands possibilities like unleashed thinking" by William Arthur Ward<br></td></tr>
<tr id="i16_0"><td> "Nothing limits achievement like small thinking, and nothign expands possibilities like unleashed thinking" by William Arthur Ward<br></td></tr>
<tr id="i17_0"><td> "Nothing limits achievement like small thinking, and nothign expands possibilities like unleashed thinking" by William Arthur Ward<br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr id="i18_0"><td> Work long play hard" UNKNOWN<br></td></tr>
<tr id="i19_0"><td> Work long play hard" UNKNOWN<br></td></tr>
<tr id="i20_0"><td> Work long play hard" UNKNOWN<br></td></tr>
<tr id="i21_0"><td> Work long play hard" UNKNOWN<br></td></tr>
<tr id="i22_0"><td> Work long play hard" UNKNOWN<br></td></tr>
<tr id="i23_0"><td> Work long play hard" UNKNOWN<br></td></tr>
<tr id="i24_0"><td> Work long play hard" UNKNOWN<br></td></tr>
<tr id="i25_0"><td> Work long play hard" UNKNOWN<br></td></tr>
<tr id="i26_0"><td> Work long play hard" UNKNOWN<br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr><td>&nbsp;< br></td></tr>
<tr>&nbsp;<br ></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr><td>&nbsp;& nbsp;&nbsp;.... ............... ............... ............... ............... ..<br></td></tr>
<tr><td>&nbsp;& nbsp;<br></td></tr>
<br>
<tr><td>&nbsp;< br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>
<tr><td>....... ............... ............... ............... ............... .....<br></td></tr>

</table>
</BODY>
</HTML>[/HTML]
Feb 15 '08 #3
Msleh08
8 New Member
Instead of using a table, do you think I can solve this problem using a Grid instead?
Feb 15 '08 #4
acoder
16,027 Recognized Expert Moderator MVP
Instead of using a table, do you think I can solve this problem using a Grid instead?
A grid? What kind of grid?

By the way, the code doesn't work at all in Firefox. Were you looking to make it work cross-browser?
Feb 16 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

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.
1
3613
by: Wesman | last post by:
Threads, textboxes and scrolling Thanks in advance for any information on this matter. I have run into a small richtextbox, scrolling and tread issue. Which has me totally confused. Instead of trying to explain it I wrote some small C# code to demonstrate the fact that in the threaded version the textbox simple doesn't scroll like it should… please look to the startButton_Click method for the distinction between the two programs..
0
2250
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...
6
1552
by: Jon Paal | last post by:
an excellent working solution for scrolling tables appears at this link http://www.litotes.demon.co.uk/example_scripts/tableScroll.html author has no contact page, but I have a question about the display of the table. the top left corner in the table grid is hidden from being displayed. I have tried to figure out where it is being hidden but can't find the code to allow it to be shown as part of the left frozen column. can anyone...
0
1015
by: The Confessor | last post by:
I've narrowed down my problem, but I've yet to find a solution, so here goes again: Private Sub Form_Main_KeyDown() Handles MyBase.KeyDown Dim PaintEventArgument As New PaintEventArgs (CreateGraphics, Nothing) If e.KeyCode = System.Windows.Forms.Keys.Left Then For XOffSet = 1 To 40 Step 1 ' Simulate scrolling. InvokePaint(Me, PaintEventArgument)
3
2721
by: Brian Tkatch | last post by:
I have a form with two DataGrids, which are kept in sync manually via Stored PROCEDURE calls. That is, when a record is selected on the first grid, a stored PROCEDURE is CALLed to Fill() the next second DataGrid's DataSource. All that works very well. And, when there are no records to display, it is simply left blank. My issue is that when i scroll the first one, sometimes the second grid shows a bunch of null values (a "new" record). ...
17
4760
by: pigeonrandle | last post by:
Hi, I have seen loads of different ways to do this, but the all seem to yield the same result - text that doesn't flicker when it's moving too slowly! Does anyone know 'the best way' to make text scroll... eg Override OnPain and OnPaintBackground Override WndProc
7
2912
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt enough memory' error whenever I scroll past N number of bytes in a textbox that has been filled with a lot of data. I am not sure what N is, but for a large chunk of data it occurs at about the halfway scroll, and smaller chunks might not throw...
8
3373
by: rmurgia | last post by:
Has anyone noticed that scrolling through objects i.e. forms, reports, tables, etc with Access 2007 is not as easy as Access 2003? I have a database with a large number of objects. When scrolling through with the down arrow or page down, it seems that items get caught in the buffer making scrolling through large amounts of objects cumbersome. After taking my finger off the key, the cursor continues to move. If I push down and let go quickly,...
0
9710
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
10593
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
10340
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...
0
9163
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
6858
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();...
0
5527
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
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
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...

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.