473,395 Members | 1,578 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,395 software developers and data experts.

Scrolling Issue

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 1391
acoder
16,027 Expert Mod 8TB
Show your code or, better still, a link to a test page.
Feb 15 '08 #2
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{border-collapse: collapse; border: 0px solid black;}//code helped by unknown source on codingforums.com
.tableExample tr td{cursor:pointer; border: 0px solid black; padding: 0px;}
.odd{background-color:#F5DEB3';}
.even{background-color:#F5DEB3';}
.high{background-color:#FFFF00;font-size:medium;font-weight:bold;position:static;}
.selected{background-color:#FFFF00;font-size:medium;font-weight:bold;}
</style>

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

var table = {};

table.keys = {
AddNew : function(id,action){
this.monitorActions[id] = action;
this.quickLookup.push(id);
},
monitorActions : new Array(),
quickLookup : new Array()
}

table.ActiveTable = null;

table.SelectableLSPEC = function(tableId,activate){
var ref = this;
this.tableId = tableId;
this._init();
this.selectedId = null;
table.keys.AddNew(tableId,ref);
if(activate){
table.ActiveTable = tableId;
this.selectFirst();
}
}

table.SelectableLSPEC.prototype._init = function(){
var ref = this;
var elemTable = document.getElementById(this.tableId);
var rows = elemTable.getElementsByTagName("tr");
var cnt = rows.length;
for(var i=0; i<cnt;i++){
var className = (i%2)?"odd":"even";
rows[i].className = className;
rows[i].defaultClassName = className;
rows[i].onmouseover = function(){if(this.className!="selected")this.clas sName="high";}
rows[i].onmouseout = function(){if(this.className!="selected")this.clas sName=this.defaultClassName;}
rows[i].onclick = function(){ref.select(this)};
}
elemTable = null;rows=null;
}

table.SelectableLSPEC.prototype.select = function(elem){
this.removeSlections();
this.selectedId = (this.selectedId!=elem.id)?elem.id:null;
if(this.selectedId!=null)elem.className = "selected";

}

table.SelectableLSPEC.prototype.removeSlections = function(elem){
var elemTable = document.getElementById(this.tableId);
var rows = elemTable.getElementsByTagName("tr");
var cnt = rows.length;
for(var i=0; i<cnt;i++)rows[i].className = rows[i].defaultClassName;
elemTable=null; rows=null;
}

table.SelectableLSPEC.prototype.selectFirst = function(){

var elemTable = document.getElementById(this.tableId);
var firstRow = elemTable.getElementsByTagName("tr")[0];
firstRow.className = "selected"
this.selectedId = firstRow.id;
elemTable=null; firstRow=null;

}

table.SelectableLSPEC.prototype.keyClick = function(keyCode){
var direction = (keyCode==38)?-1:(keyCode==40)?1:0;
if(direction!=0){
this.selectNext(direction);
}
}

table.SelectableLSPEC.prototype.selectNext = function(dir){

var elemTable = document.getElementById(this.tableId);
var rows = elemTable.getElementsByTagName("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].defaultClassName;
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.srcElement:evt.target;

while(theElem!=null){
if(table.keys.quickLookup.indexOf(theElem.id) != -1){
table.ActiveTable = theElem.id;
return true;
}
theElem = theElem.offsetParent;
}
table.ActiveTable = null;
return true;
}


function handleKeyPress(e){
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
if(table.ActiveTable){
table.keys.monitorActions[table.ActiveTable].keyClick(keycode);
}
}

document.onclick = monitorClick;
document.onkeydown = handleKeyPress;

</script>
</head>
<body style='background-color: #F5DEB3' class='BlackFont'>
<table class="tableExample" id="tableExample1">
<tr id="i2_0"><td>.................................... ....................................<br></td></tr>
<tr id="i3_0"><td>..............Hello World.......Hello World......Hello World.......<br></td></tr>
<tr id="i4_0"><td>..............Hello 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
Instead of using a table, do you think I can solve this problem using a Grid instead?
Feb 15 '08 #4
acoder
16,027 Expert Mod 8TB
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
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...
1
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...
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...
6
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...
0
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...
3
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...
17
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...
7
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...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.