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 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question [ASK]Overlay?? Is that possible?

    Is that possible if we wanna 'destroy' all the current page html content, and then replace it with the new one using javascript?
    Please tell me folks?!

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think it kind of depends what you mean by "all". All visible info on the page? All info even non-visible? You can try something like this to see what might answer your question.

    <button onclick="document.write('hi');">Hi</button>

    david_kw

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I guess you must detail your aim. You may do that using javascript, but why to do to that when you may simply load another page...?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I mean the visible one to be replaced..
    Yeah, that example you given is working like an overlay.
    But what about the full HTML page to be replaced??
    I'm looking for these anywhere, but not find it out...

  • #5
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm sure I drive Kor crazy with my non-DOM answers but how about this!

    Code:
    <button onclick="document.getElementsByTagName('body')[0].innerHTML='<div>Click <a href=\'http://www.google.com\'>here</a> to go to Google.</div>';">Make new page</button>
    I have to admit I still don't understand what you are trying to achieve.

    david_kw

  • #6
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    okay thanks its working, but only replaced the body tag..
    what about all inside the HTML tag to be replaced?
    Can this be done?

  • #7
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok I'm done guessing. First I showed one way to overwrite the whole thing and you said you only wanted the visible stuff replaced. Then I showed a way to replace the body and you want to replace more. I'd need solid information on what you do and don't want changed to try and help more.

    david_kw

  • #8
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, sorry for the less info i've given...
    The detail is:
    I want to replace all the tag inside the HTML tag..
    including head and body tag...

    So that's it..
    I wanted to make a site that when some1 click the link the page are all updated with the new one..

  • #9
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well I don't have any idea how to set everything between the <html> tags. From my limited tests the

    document.getElementsByTagName('html')[o].innerHTML =

    assignment didn't work.

    But it seemed to work to overwrite the whole page using document.write() as shown in this test.

    Code:
    <html>
      <head>
        <title>Old Page</title>
        <script type="text/javascript">
          var htmlHead = 
            "<title>New Page</title><script>function set(){document.getElementById('adiv').innerHTML='adiv';}<\/script>";
          var htmlBody = 
            "<div>Click <a href='http://www.google.com'>here</a> to go to Google.</div><button onclick='set();'>Test DOM</button><div id='adiv' />";
          var htmlPage =
            "<html><head>" + htmlHead + "</head><body>" + htmlBody + "</body></html>";
        </script>
      </head>
      <body>
        <button onclick="document.write(htmlPage); document.close();">Replace with document.write</button>
      </body>
    </html>
    Of course, I have no idea what the ramifications are across browsers or anything else. But it was interesting that it did seem to parse it in to the DOM (as shown by the button).

    david_kw


  •  

    Posting Permissions

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