How to prevent the browser from refreshing the page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rania fayed
    New Member
    • Sep 2007
    • 1

    How to prevent the browser from refreshing the page

    i 'm using php+js+mysql in aprogram but i have aproblem happen when the user click the refresh button ,this make the date in the entry form reposted to db
    and this make agreet problem
    if someone can help me to fix this problem plz do it
    i think we can do it using js but the code i use just disable F5 but not the refresh button
    here the code:[code=javascript]
    <Script language="javas cript">
    function checkKeyCode(ev t)
    {

    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElemen t) ? evt.srcElement : null);
    if(event.keyCod e==116)
    {
    evt.keyCode=0;
    return false
    }
    }
    document.onkeyd own=checkKeyCod e;

    </script>[/code]

    and thanks
    Last edited by pbmods; Sep 4 '07, 03:22 PM. Reason: Added CODE tags.
  • AMT India
    New Member
    • Feb 2007
    • 64

    #2
    Originally posted by rania fayed
    i 'm using php+js+mysql in aprogram but i have aproblem happen when the user click the refresh button ,this make the date in the entry form reposted to db
    and this make agreet problem
    if someone can help me to fix this problem plz do it
    i think we can do it using js but the code i use just disable F5 but not the refresh button
    here the code:
    <Script language="javas cript">
    function checkKeyCode(ev t)
    {

    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElemen t) ? evt.srcElement : null);
    if(event.keyCod e==116)
    {
    evt.keyCode=0;
    return false
    }
    }
    document.onkeyd own=checkKeyCod e;

    </script>

    and thanks

    dont go to js...just give a header after ur insert query. The same url of the page shuld be given there...example below

    [code=php]
    header("Locatio n:abc.php....ur url");
    [/code]

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, Rania. Welcome to TSDN!

      Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

      Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

      Comment

      Working...