我想用 Javascript 确定页面的 URL。这可能吗? 我怎样才能实现这个目标? 非常感谢
最佳答案
根据您是否需要哈希、查询字符串等,有许多不同的属性可用。
例如,在此页面上;
window.location.hash: "#11537761";
window.location.host: "stackoverflow.com";
window.location.hostname: "stackoverflow.com";
window.location.href: "http://stackoverflow.com/questions/11537718/how-to-determine-the-page-url-at-run-time-in-javascript/11537761#11537761";
window.location.origin: "http://stackoverflow.com";
window.location.pathname: "/questions/11537718/how-to-determine-the-page-url-at-run-time-in-javascript/11537761";
关于c# - 如何在 Javascript 中确定运行时的页面 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11537718/