如何通过单击浏览器的后退按钮强制所有Web浏览器重新加载页面?

时间:2018-02-22 12:01:49

标签: javascript php html

我有一个管理页面,其中用户更新了该号码,但是当我点击后退按钮时,它仍然显示文本框中的旧值,这是我的代码。



<?php
//following code to update the ticket avaiable number
if(isset($save))
{
//To insert number into database
	Data::getupdate($ticketsavailable);	
	print('<script>window.location.href="https://ct.org/gun-drawing-nocache1/"</script>');
}
//following code for to show the available tickets on the text box
$ticketleft = "";
//this will fetch number from database
$ticketleft = Data::getticketsavailable();

}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>update page</title>
</head>
<body>
<form action="" enctype="multipart/form-data" method="post">
<label class="update_heading"> Update Gun Drawing Tickets </label> <br>
  <label for="update" class="update"> Update Number: </label><input type="textbox" id="ticketsavailable" name="ticketsavailable" value="<?php
                         echo  $ticketleft[0]->ticket_available ;?>" >
						 <br><br>
  <input type="submit" name="save" value="Submit">


 <script type="text/javascript">    
// If persisted then it is in the page cache, force a reload of the page.
        window.onpageshow =function(event){
            if(event.persisted){        
                document.body.style.display ="none";        
                location.reload();
            }
        };
</script>
</form> 
</body>
</html>
&#13;
&#13;
&#13;

//我使用过javascript:但它对Chrome无效 我也尝试过页面上的标题仍然无法正常工作。 标题(&#34; Expires:Thu,1981年11月19日08:52:00 GMT&#34;); //过去的日期 header(&#34; Cache-Control:no-store,no-cache,must-revalidate,post-check = 0,pre-check = 0&#34;); //HTTP/1.1 标题(&#34; Pragma:no-cache&#34;);

0 个答案:

没有答案