<?php echo $_GET['action']; ?> <!doctype html> <html lang="zh"> <head> <meta charset="UTF-8"> <title>Document</title> <script> function gogo(){ location.href = '?action=login'; } </script> </head> <body> <input type="button" value="测试location.href" onclick="gogo()"/> </body> </html>
当前页面是http://localhost:8084/test.php
点击按钮后location.href = http://localhost:8084/test.php?action=login;
location.href = '?action=login'; 这种设置直接在当前页面加参数