Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在浏览器(IE、FireFox等)中使用javascript获取当前页面的域名?
如果您询问提供当前页面的主机的机器名称,您可以使用
window.location.hostname
如果您询问在浏览器中显示页面的机器的名称,则出于安全目的,浏览器会限制该信息。
您可以使用document.domain获取域名。
document.domain
window.location.host
编辑:如果您的意思是客户端机器的域,我认为这是不可能的。