对于网站建设来说,通常会需要遇到js跨域抓取的问题,那么对于初学者来说,都不知道该怎么来解决,对此,郑州网站建设公司燚轩科技就来跟大家好好的分析解答一下吧。
源代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
var url;
url = window.location.href; /* 获取完整URL */
alert(url); /* http://127.0.0.1:8020/Test/index.html#test?name=test */
url = window.location.pathname; /* 获取文件路径(文件地址) */
alert(url); /* /Test/index.html */
url = window.location.protocol; /* 获取协议 */
alert(url); /* http */
url = window.location.host; /* 获取主机地址和端口号 */
alert(url); /* http://127.0.0.1:8020/ */
url = window.location.hostname; /* 获取主机地址 */
alert(url); /* http://127.0.0.1/ */
url = window.location.port; /* 获