Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2010, 10:30 PM
Registered User
 
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation How to disable scrolling

I was wondering if anyone knew how to disable scrolling in a text box?
 
Old October 23rd, 2010, 12:45 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

No, it's not possible to disable scrolling. The internal behavior of form components is one of the hardest things to control. From browser to browser different items are hard coded, e.g. Opera and Safari make cross-browser form styling much more difficult because they impose certain style features which IE and FF are more willing to defer to your stylesheet on. So this is one of the nastiest topics in HTML which makes it difficult to create designs which will work reliably for the entire audience of users who visit your website.

The scroll bar of a <textarea> element is default behavior in all browsers. It works as if the textarea had the CSS declaration overflow: auto; If the content fits, then there's no scrollbar, but if the content exceeds the visible area of the textarea, then it is clipped and a scrollbar appears. (Note: in some browsers, the scrollbar is visible all the time but simply appears inactive (grey color) when not needed.

You can play with the overflow property and remove the scrollbar, but people can still use the arrow keys to move up and down through everything they've written so that "might" work depending on why you want to disable scrolling.

A better choice may be to use <input type="text"> That will only allow them to type on one line so there is no issue with scrollbars. And if your goal is to limit the amount that they can type, the <input type="text"> element has a major advantage, it supports a maxlength attribute which specifies how many characters someone can type into the field. That's the only way you can really limit how much users can type in. It's used a lot for address forms set to 2 for state and 5 for zip codes so that people have to use the correct number of digits (it won't stop a hacker, but it's a good usability tool). Textarea has no way to limit user input.

Hope that helps, if it doesn't please explain the "purpose" you're trying to achieve and maybe we can assist further.
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
 
Old October 23rd, 2010, 01:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Are we talking about a TEXTAREA? It's possible, but not advisable, to remove the scrollbars with 'overflow: hidden'. The user will still be able to scroll with the arrow keys though.
__________________
--
http://yupapa.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Scrolling BDrake BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 1 February 9th, 2009 04:14 PM
Disable View>Source (disable html source) kazmughal44 HTML Code Clinic 11 December 11th, 2007 11:53 AM
how to disable horizontal scrolling aliinal Javascript 1 October 27th, 2005 01:41 AM
scrolling smn2 Classic ASP Professional 1 August 28th, 2003 06:57 AM
Scrolling smn2 Classic ASP Basics 0 August 28th, 2003 05:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.