一、js獲取當前域名
方法1: var domain = document.domain;
方法2:var domain = window.location.host;
二、獲取端口號
var port = location.port; //獲取端口號
var host = location.host; //獲取主機名+端口號 例如:172.20.11.111:8000
三、獲取當前URL
var url = window.location.href;
var url = self.location.href;
var url = document.URL;
var url = document.location;
ie 地址欄顯示的是什么,獲取到的 url 就是什么。
原文鏈接:https://blog.csdn.net/u012577474/article/details/99691877