Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help...about InnerHTML

    sorry, i cant speak english well..
    I have problem..

    example..

    <html>
    <body>
    <div id="top">bla bla bla</div>
    <script>
    document.getElementById('top').innerHTML='<div>new content top</div>';
    document.getElementById('bottom').innerHTML='<div>new content bottom</div>';</script>
    <div id="bottom">bla bla bla</div>
    </body>
    </html>

    the blue script is not working.,.
    i wanna the blue script still working without changing the position ( above div bottom )

    Thanks lot friends

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts
    I can't see any reason why u perist having script there. If u leave it there it won't work.

    to sumarize, why you want to put 'new content bottom' when there is no 'previous content bottom'? You do actualy have something there, but it is not displayed to user , so there is no use of it.

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    The bottom div is not changed because the script is run before that element has been rendered

    Try it this way

    PHP Code:
    <script type="text/javascript">

    onload=function test(){
    document.getElementById('top').innerHTML='new content top';
    document.getElementById('bottom').innerHTML='new content bottom';
    }

    </script>

    <div id="top">bla bla bla</div>
    <div id="bottom">bla bla bla</div> 
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •