473,382 Members | 1,752 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,382 software developers and data experts.

Text Not Being Displayed

Hi,
I've been trying for some time now to get the height (the 'scrollable'
height) of the current page (Thanks to Martin Honnen for help so far). I
feel as though I am almost there, but am having an unusual problem. (Please
see the code at the end of this page.)

The text "This text isn't being displayed" isn't, as you might have guessed,
being displayed.

I can't seem to display any 'normal' content unless I include it in the
<script>.

Why?

Why, why why?

Hope you can help,

Paul

----------

<html>
<head>
<title>Display Page Height</title>
<SCRIPT TYPE="text/javascript">
<!--
function pageHeight()
{
docHeight = 0;
if (typeof document.height != 'undefined')
{
docHeight = document.height;
}
else if (document.compatMode && document.compatMode != 'BackCompat')
{
docHeight = document.documentElement.scrollHeight;
}
else if (document.body && typeof document.body.scrollHeight != 'undefined')
{
docHeight = document.body.scrollHeight;
}
writeHeight(docHeight);
}
window.onload = pageHeight;
//-->
</SCRIPT>
</head>
<body>
<p>This text isn't being displayed!</p>
<SCRIPT TYPE="text/javascript">
<!--
function writeHeight(height)
{
document.write("Document has a height of " + height);
}
//-->
</SCRIPT>
</body>
</html>
Jul 20 '05 #1
6 1820
Paul wrote:
Hi,
I've been trying for some time now to get the height (the
'scrollable' height) of the current page (Thanks to Martin Honnen for
help so far). I feel as though I am almost there, but am having an
unusual problem. (Please see the code at the end of this page.)

The text "This text isn't being displayed" isn't, as you might have
guessed, being displayed.


well, it actually is displayed under Opera 7.21 but if and only if you
remove the script:

<SCRIPT TYPE="text/javascript">
<!--
function writeHeight(height)
{
document.write("Document has a height of " + height);
}
//-->
</SCRIPT>
Jul 20 '05 #2
> The text "This text isn't being displayed" isn't, as you might have
guessed,
being displayed.
It *is* being displayed, just not for very long.
Why?
Do a 'View source' on the page and you may see what has happened.
Why, why why?


When you call document.write after the page has been parsed you are
overwriting the page, not appending to it.
Jul 20 '05 #3
"karambol" <ka******@euro26.org.pl> wrote in message
news:3f******@news.vogel.pl...
Paul wrote:
Hi,
I've been trying for some time now to get the height (the
'scrollable' height) of the current page (Thanks to Martin Honnen for
help so far). I feel as though I am almost there, but am having an
unusual problem. (Please see the code at the end of this page.)

The text "This text isn't being displayed" isn't, as you might have
guessed, being displayed.


well, it actually is displayed under Opera 7.21 but if and only if you
remove the script:

<SCRIPT TYPE="text/javascript">
<!--
function writeHeight(height)
{
document.write("Document has a height of " + height);
}
//-->
</SCRIPT>


So, If I remove the functionality of the script, I can display basic HTML?

Anyone got any real suggestions?
Jul 20 '05 #4
"Graham J" <in***************@orangebucket.co.uk> wrote in message
news:bn*************@ID-203032.news.uni-berlin.de...
The text "This text isn't being displayed" isn't, as you might have

guessed,
being displayed.


It *is* being displayed, just not for very long.
Why?


Do a 'View source' on the page and you may see what has happened.
Why, why why?


When you call document.write after the page has been parsed you are
overwriting the page, not appending to it.


Ah, I see - thanks.

Now the problem has been identified, I need a solution!

Is there anyway to append to the page rather than overwrite it entirely?

Thanks for you help - I'm very grateful,

Paul
Jul 20 '05 #5
> Ah, I see - thanks.

Now the problem has been identified, I need a solution!

Is there anyway to append to the page rather than overwrite it

entirely?

Well I don't know exactly what you are trying to achieve so it might
be that you can do what you want just by triggering scripts at the
bottom of your markup before the </body> when just about everything is
in place but the page hasn't finished loading. However whatever you
are trying to do requires the page to have been fully loaded then you
have to work with the elements you have on the page already. You
probably need to read up on 'innerHTML'. For example you could have
an empty <div> at the end of the page and write content into that.

Jul 20 '05 #6
Anyone got any real suggestions?


Here's your "REAL" suggestion. and a solution too.

All you've got to do is to create a block of text (may be <p>, nay be
div, doesn't matter) give it an id and then change it's innerHTML in
the script. this works for IE and Opera, but i don't think it will for
mozilla, so keep searching.

<html>
<head>
<title>Display Page Height</title>
<SCRIPT TYPE="text/javascript">
<!--
function pageHeight()
{
docHeight = 0;
if (typeof document.height != 'undefined')
{
docHeight = document.height;
}
else if (document.compatMode && document.compatMode != 'BackCompat')
{
docHeight = document.documentElement.scrollHeight;
}
else if (document.body && typeof document.body.scrollHeight !=
'undefined')
{
docHeight = document.body.scrollHeight;
}
writeHeight(docHeight);
}
window.onload = pageHeight;
//-->
</SCRIPT>
</head>
<body>
<p>This text isn't being displayed!</p>
<p id="foo"></p>
<SCRIPT TYPE="text/javascript">
<!--
function writeHeight(height)
{
document.all('foo').innerHTML = "Document has a height of " + height;
}
//-->
</SCRIPT>
</body>
</html>
Jul 20 '05 #7

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

Similar topics

1
by: Stefan De Schepper | last post by:
Hi all, I made an overview of all my contacts. This overview is shown in a ListView. I programmatically add as many columns as there are in my contacts database table. All the contacts and their...
0
by: Krzysztof Fink-Finowicki via .NET 247 | last post by:
I have problem with TEXTAREA HTML tags in my Web application (MSIE 6.0). User fills-in content of TEXTAREA on HTML dialog window. After accepting, content of TEXTAREA from dialog window is...
7
by: Matt | last post by:
Is there a way to increase the amount of time a hyperlink title displays or show the desired text using javascript? <a title="This is the title text displayed on hover.">Displayed Text</a> ...
9
by: Susan Bricker | last post by:
Greetings. I am having trouble populating text data that represents data in my table. Here's the setup: There is a People Table (name, address, phone, ...) peopleID = autonumber key There...
3
by: Rigga | last post by:
Hi all, Firstly, sorry for the simple question, as i'm sure i'm missing something obvious. I have a text field (varchar) I am reading from an SQL db, into a string variable, in .NET I am...
4
by: Mark L. Breen | last post by:
Hello Guys and Galls, I use combos on my forms. The code to initialise the combos is as follows Dim dsPIDTypes As DataSet dsPIDTypes = PartDB.GetPIDTypes ' Returns a dataset object...
11
by: Chris Ianson | last post by:
Hi all, Well having found this group to be a fountain of knowledge I have another question. And hey, no worries if you don't know or don't want to answer, please ignore this. Is there a way...
4
by: farhanm84 | last post by:
I have a requirement to display the link in colum format in IE browser. The link text is associated with an image (double arrow). Since the text of the link is large enough to set in one of the...
4
by: Mudcat | last post by:
I've tried quite a few things to get this correct but have hit a couple of sticking points that I can't figure out. I need to ge the Text box to function like the 'wraplength' option in a Label. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.