如何从子域名获取域名?
像这样:
URL ->输出
m.gigabyte.com -> gigabyte.com
forums.localhost ->本地主机
我试过了:
var domain = window.location.host.split( '.' );
window.location = 'http://' + domain[1] + domain[2] + window.location.pathname;但它在本地主机上似乎不起作用。我只想剥离子域而不再是.com, .org, .net的.
发布于 2014-05-19 19:48:08
这样如何:
var subdomain = 'aaaa.bbb.ccc.com';
var dotIndex = subdomain.indexOf('.');
var maindomain = subdomain.substr(dotIndex+1);https://stackoverflow.com/questions/23736495
复制相似问题