473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

revealing content

If I have a div set as follows:

<div id="div_1" style="position:absolute; z-index:1; left:33px;
top:177px; height:20px; width:910px; visibility:visible;
overflow:hidden; border:1px solid red;">alot of content here that varies
in length</div>

and trying to incrementally reveal the content using the following
javascript until the height is equal to "222"

function extend()
{
var obj = document.getElementById('div_1')
var amt = "222";
setTimeout(int_a, 100);
function int_a()
{
var currH = obj.style.height
var currHS = currH.split("px")
if ( parseInt(currHS) < amt )
{
var newH = (parseInt(currHS)+1) + "px"
obj.style.height = newH
setTimeout(int_a, 50);
}
}
}

How to I make a change to reveal the content until all the content is
revealed instead of harcoding a value like I have done above?

Mike
Jul 23 '05 #1
2 1154
Michael Hill wrote:
If I have a div set as follows:

<div id="div_1" style="position:absolute; z-index:1; left:33px;
top:177px; height:20px; width:910px; visibility:visible;
overflow:hidden; border:1px solid red;">alot of content here
that varies in length</div>

and trying to incrementally reveal the content using the
following javascript until the height is equal to "222"

function extend()
{
var obj = document.getElementById('div_1')
var amt = "222";
setTimeout(int_a, 100);
function int_a()
{
var currH = obj.style.height
var currHS = currH.split("px")
if ( parseInt(currHS) < amt )
String.prototype.split should return an Array, which, when passed to
parseInt, will be converted to a String and then parsed into a number.
Quite an inefficient way of trimming the final "px" from the
style.height value. parseInt stops attempting to interpret its input as
a number when it encounters a character that cannot be a numeric digit
in the radix specified (or not as the second argument is optional, but
advisable) (except when interpreting hex as a leading 0x would be
acceptable as signifying a hex number).

<snip> How to I make a change to reveal the content until all the content is
revealed instead of harcoding a value like I have done above?


Nesting elements. You put the contents in another positioned DIV inside
the first but you do not constrain its height dimension. Then reading
the height of the inner DIV will tell you the maximum value needed to
fully reveal it in the outer DIV. You would probably read the height
from the - offsetHeight - property of the DIV element, baring in mind
that some browsers do not impediment any element dimension reporting
properties (requiring sensible planned clean degradation for those
cases).

Richard.
Jul 23 '05 #2
> > function int_a()
{
var currH = obj.style.height
var currHS = currH.split("px")
if ( parseInt(currHS) < amt )


String.prototype.split should return an Array, which, when passed to
parseInt, will be converted to a String and then parsed into a number.
Quite an inefficient way of trimming the final "px" from the
style.height value. parseInt stops attempting to interpret its input as
a number when it encounters a character that cannot be a numeric digit
in the radix specified (or not as the second argument is optional, but
advisable) (except when interpreting hex as a leading 0x would be
acceptable as signifying a hex number).


Richard how would you do this?
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: jonathan.beckett | last post by:
Hi All, For the past few months I have been working on an open source Apache/PHP/MySQL content management system - and have recently made it available for download. It's still very much a...
0
by: jonathan.beckett | last post by:
Hi All, I have just made version 0.4.8 of the PluggedOut CMS Content Management System available for download - it's free, and covered by the GPL. It's still very much a work in progress...
0
by: Scott Abel | last post by:
For immediate release: The Rockley Group Content Management Workshop Series Coming to Atlanta, Seattle, Vancouver, Chicago, Washington, DC, Toronto, and Research Triangle Park Learn more:...
0
by: Everything Jute ! | last post by:
Very revealing c# tutorial http://www.csharphelp.com/archives2/archive402.html Especially when he uses the gcc windos compiler ( minGW ) in lesson 4 ! -- Jute for Bush '04
10
by: clintonG | last post by:
Can somebody direct me to documents or source that supports the use of collapsible content that is collapsed by default when the page is loaded? The secondary objective would of course be...
0
by: Papa Hemingway | last post by:
MIME-Version: 1.0 Content-Type: Text/Plain; charset=US-ASCII http://w3.intrak.tuke.sk/~bona/jop/att-0476/ouch3.jpg
16
by: Ed Mullen | last post by:
I've investigated a bit how to have hidden lines of text (could be just text or could be links) appear when clicking on a link in an HTML page. Example describing what I'd like it to look like is...
17
by: ApexData | last post by:
Hello Split DB (FE & BE) Linked. FE compiled to MDE. For security reasons, I have hidden the BackEnd. However, If the network is down or the FE can't find the Backend, then an Access Error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.