Text Not Being Displayed 
July 20th, 2005, 11:23 AM
| | | 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> | 
July 20th, 2005, 11:23 AM
| | | Re: Text Not Being Displayed
Paul wrote:
[color=blue]
> 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.
>[/color]
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> | 
July 20th, 2005, 11:23 AM
| | | Re: Text Not Being Displayed
> The text "This text isn't being displayed" isn't, as you might have
guessed,[color=blue]
> being displayed.[/color]
It *is* being displayed, just not for very long.
[color=blue]
> Why?[/color]
Do a 'View source' on the page and you may see what has happened.
[color=blue]
> Why, why why?[/color]
When you call document.write after the page has been parsed you are
overwriting the page, not appending to it. | 
July 20th, 2005, 11:23 AM
| | | Re: Text Not Being Displayed
"karambol" <karambol@euro26.org.pl> wrote in message
news:3f9d3893@news.vogel.pl...[color=blue]
> Paul wrote:
>[color=green]
> > 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.
> >[/color]
>
> 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>[/color]
So, If I remove the functionality of the script, I can display basic HTML?
Anyone got any real suggestions? | 
July 20th, 2005, 11:23 AM
| | | Re: Text Not Being Displayed
"Graham J" <individual-news-7@orangebucket.co.uk> wrote in message
news:bnje0l$11qbf1$1@ID-203032.news.uni-berlin.de...[color=blue][color=green]
> > The text "This text isn't being displayed" isn't, as you might have[/color]
> guessed,[color=green]
> > being displayed.[/color]
>
> It *is* being displayed, just not for very long.
>[color=green]
> > Why?[/color]
>
> Do a 'View source' on the page and you may see what has happened.
>[color=green]
> > Why, why why?[/color]
>
> When you call document.write after the page has been parsed you are
> overwriting the page, not appending to it.
>
>[/color]
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 | 
July 20th, 2005, 11:23 AM
| | | Re: Text Not Being Displayed
> Ah, I see - thanks.[color=blue]
>
> Now the problem has been identified, I need a solution!
>
> Is there anyway to append to the page rather than overwrite it[/color]
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. | 
July 20th, 2005, 11:24 AM
| | | Re: Text Not Being Displayed
[color=blue]
> Anyone got any real suggestions?[/color]
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> | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,989 network members.
|