473,669 Members | 2,395 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 1402
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
3604
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
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...
6
1543
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
1010
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
2708
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
4708
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
2890
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
3364
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
8383
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,...
0
8809
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
8588
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
8658
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5682
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
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2797
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
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
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.