url = window.location.hostname; // get host name like http://www.baidu.com
var res = url.split(‘.‘); // split by dotvar top_level_domain = res[res.length - 1]; // get last element in array console.log(top_level_domain); // com
时间: 2024-10-13 11:56:00