spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / javascript / ne / 1

To page 1current pageTo page 3
[previous][next]

Combining all HTML code together and removing embedded style information:

Arrow Keys Scrolling

Firefox has a nice feature that allows setting the cursor in an input control (in spite of being read-only) and moves forward and backwards with left and right arrow keys. Unfortunately, neither IE nor Opera have this feature. A risky alternative would be leaving the input control as a regular one without the readonly property. Risky because regular input controls are meant to type text on them, in contrast to readonly input controls that prevents any typing. This alternative, will force you to code onkeypress or onkeydown events to block any non desirable keys typed by the user, and allow any keys that permit cursor movement, such as left arrow, right arrow, home and end keys. Moreover, making this alternative cross-browser needs extra coding like onpaste event for IE and oninput event for mozilla based browsers.

Mouse Scrolling

If you want to get rid of the problem mentioned above, an easier technique consists of showing arrow images every time the mouse is over table cells, and uses these arrows to scroll the text forwards and backwards. However, if the text fits entirely in the table cell, arrow images shouldnt appear because scrolling is not needed.

How do we determine the length of the displayed text? String length is not equal to length in pixels. (I know you already know this. :)

There is a property called boundingWidth that retrieves the width of the rectangle that bounds the text contained in the input control but it only works in IE.

To know the width of any String, a SPAN element is created and its innerHTML property is set equal to the text of the table cell. Until the browser renders that element, offsetWidth property is always 0. Therefore, the span element is appended to the document body and after getting its width, the span is removed:

After getting the text width, we can compare it to the input width, and if the text width is shorter than the input width, scroll arrows are not shown.

Text scrolling is straightforward and you might find lots of examples on the Internet. In our case, two images are hidden in the document and repositioned every time the mouse goes over the desired input control.

These arrow images are repositioned using getX and getY functions:

 

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / javascript / ne / 1

To page 1current pageTo page 3
[previous][next]

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Symantec Whitepaper: Converging System and Data Protection for Complete Disaster Recovery
Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
  Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Symantec Whitepaper: Comprehensive Backup and Recovery of VMware Virtual Infrastructure
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Fixing MySQL Replication · Firewall Guide: First Steps to Securing the Enterprise · VoxOx Tames the Tumultuous Communications Tangle

Created: June 20, 2006
Revised: August 3, 2006

URL: http://webreference.com/programming/javascript/ne/1