views:

68

answers:

1

I have an image selector that allows to choose an image from a gallery, then fills in the URL into a <input type="text"> field. The URLs can be awfully long, and always seeing the first half of the URL in the text field has very little informational value.

Does somebody know a way to "scroll" to the very right of the text field so that the end of the URL is visible instead of the beginning? Without resorting to a textarea.

+1  A: 

Consider to make use of the dir (direction) attribute which you set to rtl (right-to-left).

E.g.

<input dir="rtl" value="http://stackoverflow.com/questions/1962168/scroll-to-the-very-right-of-a-long-text-input"&gt;
BalusC
didn't know about this! thanks
Luca Matteis
Very clever idea, but it changes the input behaviour for the user if they have to edit the URL manually (it behaves like a text-align: right).
Pekka
Use some JS to change the `dir` attribute on focus and blur.
BalusC
@Downvoter: please post your answer here if you think you can do it better.
BalusC