Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Oats

macrumors regular
Original poster
Jan 8, 2003
194
1
New York
Hi,
I am actually attempting to develop a widget, where I am using a console for users to enter text, and receive a response. I am using a TEXTAREA HTML object for the main console, but I am having trouble with the scrolling. In most browsers, you can force the scroll position to the end of the textarea with this code:
Code:
textareaelem = document.getElementById('mytextarea');
textareaelem.scrollTop = textareaelem.scrollHeight;

but this doesn't work in Safari or dashboard. I don't get any javacsript errors or warnings, either. Interestingly, it does appear to work with WebKit.

Developing a widget has so far been a VERY frustrating experience, and I have found that Safari's support for javascript leaves much to be desired, and can be very quirky, especially compared to Firefox.
 

jeremy.king

macrumors 603
Jul 23, 2002
5,479
1
Holly Springs, NC
Have you tried seeing what the values of textareaelem.scrollTop and textareaelem.scrollHeight actually are?

Or try using a fixed number to see what the behavior might be.

textareaelem.scrollTop = 200;

Also, I know you don't have to but have you tried playing with the overflow CSS attribute for that textarea?
 

Oats

macrumors regular
Original poster
Jan 8, 2003
194
1
New York
I have tried some CSS modifications, currently I have this:
Code:
overflow-y: scroll;

any other CSS attributes i may need to set?

i will have to look more into what the values of those scroll variables are. is there anything I can send to re-draw the textarea? Like perhaps the scroll values are being updated fine, but just not triggering an update to redraw the control?
 

Oats

macrumors regular
Original poster
Jan 8, 2003
194
1
New York
As I enter text and scroll around the textarea manually, scrollTop always remains at 0 and never changes. The scrollHeight also stays constant at 200px, which is the initial height of the textarea, and never changes. Even if I attempt to change the value of scrollTop by setting equal to some constant number, it never changes. This works in every other browser but safari.

Any other help or input would be very much appreciated!!
 

Oats

macrumors regular
Original poster
Jan 8, 2003
194
1
New York
It appears that Safari does not support javascript for scrolling textarea objects, only div objects.

so here is plan B:
create a fake keyboard event and process it, specifically a "END" keydown event which should scroll to the end of the textarea. Anyone know how to create a keydown event object and process it?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.