Connecting Tech Pros Worldwide Help | Site Map

Text Not Being Displayed

  #1  
Old July 20th, 2005, 12:23 PM
Paul
Guest
 
Posts: n/a
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>


  #2  
Old July 20th, 2005, 12:23 PM
karambol
Guest
 
Posts: n/a

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>
  #3  
Old July 20th, 2005, 12:23 PM
Graham J
Guest
 
Posts: n/a

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.


  #4  
Old July 20th, 2005, 12:23 PM
Paul
Guest
 
Posts: n/a

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?


  #5  
Old July 20th, 2005, 12:23 PM
Paul
Guest
 
Posts: n/a

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


  #6  
Old July 20th, 2005, 12:23 PM
Graham J
Guest
 
Posts: n/a

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.

  #7  
Old July 20th, 2005, 12:24 PM
karambol
Guest
 
Posts: n/a

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>
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView not being displayed: Lil silly mistake i guess.... weird0 answers 1 April 12th, 2007 10:05 PM
Session not being displayed tshad answers 1 June 27th, 2006 02:45 AM
ToolTips not being displayed when using an existing ActiveX control in a .Net Form ADavis answers 0 November 22nd, 2005 08:53 PM
ToolTips not being displayed when using an existing ActiveX control in a .Net Form ADavis answers 0 July 22nd, 2005 12:25 AM