Text Not Being Displayed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul

    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>Displa y Page Height</title>
    <SCRIPT TYPE="text/javascript">
    <!--
    function pageHeight()
    {
    docHeight = 0;
    if (typeof document.height != 'undefined')
    {
    docHeight = document.height ;
    }
    else if (document.compa tMode && document.compat Mode != 'BackCompat')
    {
    docHeight = document.docume ntElement.scrol lHeight;
    }
    else if (document.body && typeof document.body.s crollHeight != 'undefined')
    {
    docHeight = document.body.s crollHeight;
    }
    writeHeight(doc Height);
    }
    window.onload = pageHeight;
    //-->
    </SCRIPT>
    </head>
    <body>
    <p>This text isn't being displayed!</p>
    <SCRIPT TYPE="text/javascript">
    <!--
    function writeHeight(hei ght)
    {
    document.write( "Document has a height of " + height);
    }
    //-->
    </SCRIPT>
    </body>
    </html>


  • karambol

    #2
    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(hei ght)
    {
    document.write( "Document has a height of " + height);
    }
    //-->
    </SCRIPT>

    Comment

    • Graham J

      #3
      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.


      Comment

      • Paul

        #4
        Re: Text Not Being Displayed

        "karambol" <karambol@euro2 6.org.pl> wrote in message
        news:3f9d3893@n ews.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(hei ght)
        > {
        > 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?


        Comment

        • Paul

          #5
          Re: Text Not Being Displayed

          "Graham J" <individual-news-7@orangebucket. co.uk> wrote in message
          news:bnje0l$11q bf1$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


          Comment

          • Graham J

            #6
            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.

            Comment

            • karambol

              #7
              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>Displa y Page Height</title>
              <SCRIPT TYPE="text/javascript">
              <!--
              function pageHeight()
              {
              docHeight = 0;
              if (typeof document.height != 'undefined')
              {
              docHeight = document.height ;
              }
              else if (document.compa tMode && document.compat Mode != 'BackCompat')
              {
              docHeight = document.docume ntElement.scrol lHeight;
              }
              else if (document.body && typeof document.body.s crollHeight !=
              'undefined')
              {
              docHeight = document.body.s crollHeight;
              }
              writeHeight(doc Height);
              }
              window.onload = pageHeight;
              //-->
              </SCRIPT>
              </head>
              <body>
              <p>This text isn't being displayed!</p>
              <p id="foo"></p>
              <SCRIPT TYPE="text/javascript">
              <!--
              function writeHeight(hei ght)
              {
              document.all('f oo').innerHTML = "Document has a height of " + height;
              }
              //-->
              </SCRIPT>
              </body>
              </html>

              Comment

              Working...