如何取得上面網址資訊
Javascript
<script type="text/javascript"> alert('location.href: '+location.href); //輸出:http://roshikowork.blogspot.com/test.html?ppid=111#222 alert('location.protocol: '+location.protocol); //輸出: http: alert('location.hostname: '+location.hostname); //輸出: roshikowork.blogspot.com alert('location.host: '+location.host); //輸出: roshikowork.blogspot.com alert('location.port: '+location.port); //輸出 port 80 or... alert('location.pathname: '+location.pathname); //輸出: /test.html alert('location.search: '+location.search); //輸出: ?ppid=111 alert('location.hash: '+location.hash); //輸出: #222 </script>PHP
echo $_SERVER["QUERY_STRING"]; //輸出?ppid=111 echo $_SERVER['PHP_SELF']; //輸出test.html echo $_SERVER['HTTP_HOST']; //輸出roshikowork.blogspot.com echo $_SERVER["REQUEST_URI"] //輸出test.html?ppid=111#222
沒有留言:
張貼留言