Why document.write creates a new entry in browser history (how to avoid it)?

Discussion in 'Javascript' started by Trastabuga, Mar 26, 2007.

  1. Trastabuga

    Trastabuga Guest

    On the current page the user is at I need to write something like
    "Please, wait" (I am using document.write for this) and then open a
    new url with some lengthy calculation process so the page will load in
    a few seconds.
    The <body onload="redirect()"> doesn't work for me in this case, so I
    thought that if I update current page with new text no harm would be
    done. It works, but now the user will have a new page in the history
    with the same url as previous but different contents ("Please, wait"
    paragraph). I thought that browser keeps history based on new URLs,
    but looks like it's not true. How can I overwrite the content of a
    page without causing a new entry in the browser history?

    Thank you,
    Andrew
     
    Trastabuga, Mar 26, 2007
    #1
    1. Advertisements

  2. Trastabuga

    ASM Guest

    Trastabuga a écrit :
    function wait() {
    var wait = document.createElement('H1');
    wait.style.textAlign = 'center';
    wait.style.color = 'red';
    wait.style.background = '#ddd";
    wait.style.width = '100%';
    wait.style.position = 'absolute';
    wait.style.top = '50px';
    wait.innerHTML = 'Please Wait'
    document.body.appendChild(wait);
    }

    insteed of :
    document.body.appendChild(wait);
    you can have :
    document.getElementById('someWhere').appendChild(wait);
    if you want your message in div 'someWhere'
    and if this div is positioned
     
    ASM, Mar 27, 2007
    #2
    1. Advertisements

  3. Trastabuga

    ASM Guest

    Randy Webb a écrit :
    Ooops !
    I though I did correct : function waiter() { ... }
    before to post :-(
     
    ASM, Mar 27, 2007
    #3
  4. Trastabuga

    ASM Guest

    Randy Webb a écrit :
    Not too much,
    but as the variable 'wait' doesn't go away form function 'wait',
    here it is OK.

    Test with some correction(s) of typo :

    <html>
    <script type="text/javascript">
    function wait() {
    var wait = document.createElement('H1');
    wait.style.textAlign = 'center';
    wait.style.color = 'red';
    wait.style.background = '#ddd';
    wait.style.width = '100%';
    wait.style.position = 'absolute';
    wait.style.top = '50px';
    wait.innerHTML = 'Please Wait'
    document.body.appendChild(wait);
    }
    wait();
    </script>
    </html>
     
    ASM, Mar 27, 2007
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.