JS returns to the previous page and refreshes the page method

Source: Internet
Author: User
Tags php tutorial

[Guide] to go back to the previous page and then refresh the page we use the most is in the like php,asp,jsp,asp.net, below I will give you the first to introduce JS back to the previous page and refresh the page, and then put the code in PHP to implement the deletion of the current page and refresh the page. ...

JS Reload page, refresh locally, return to previous page

The code is as follows

123 <ahref="javascript:history.go(-1)">返回上一页</a><ahref="javascript:location.reload()">重载页面,本地刷新</a><ahref="javascript:history.go(-1);location.reload()">返回上一页重载页面,本地刷新</a>

Return to the first two pages and refresh the JS code should be how to write.

JS method

The code is as follows

1 <a href="#"onclick="self.location=document.referrer;">返回</a>

How the ASP automatically returns and refreshes:

The code is as follows

1 response.Write("<script language=javascript>self.location=document.referrer;</script>")

Typically used to submit an action to a page and then return to the previous page and refresh!

PHP practices

The code is as follows

1 echo "<script>alert(‘退出成功!‘);location.href=‘".$_SERVER["HTTP_REFERER"]."‘;</script>";

Set the delete success to return to the previous page and refresh

The code is as follows

12345678 if($query){$page="listrenwu.php";<!---这种方式不会刷新,只会原样返回-->echo "<script>alert(‘删除成功‘);history.go(-1)</script>";<!--//设置删除成功后返回前一页,并刷新-->-->echo "<script>alert(‘删除成功‘);window.location = "".$page."";</script>";}

This is the simplest PHP tutorial, oh, not much to say you understand.

JS returns to the previous page and refreshes the page method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.