C# 如何在Javascript中确定运行时的页面URL?

C# 如何在Javascript中确定运行时的页面URL?,c#,javascript,url,web,C#,Javascript,Url,Web,我想用Javascript确定页面的URL。这可能吗? 我怎样才能做到这一点? 非常感谢快速浏览一下谷歌: <SCRIPT LANGUAGE="JavaScript"> alert(location.href); </SCRIPT> 警报(location.href); 快速谷歌: <SCRIPT LANGUAGE="JavaScript"> alert(location.href); </SCRIPT> 警报(location.h

我想用Javascript确定页面的URL。这可能吗? 我怎样才能做到这一点? 非常感谢

快速浏览一下谷歌:

<SCRIPT LANGUAGE="JavaScript">
  alert(location.href);
</SCRIPT>

警报(location.href);
快速谷歌:

<SCRIPT LANGUAGE="JavaScript">
  alert(location.href);
</SCRIPT>

警报(location.href);
在JavaScript中

在JavaScript中,您有

根据您是否需要散列、查询字符串等,有许多不同的属性可用

例如,在本页上

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";

根据您是否需要散列、查询字符串等,有许多不同的属性可用

例如,在本页上

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";

谢谢大家!!这就是我想要的答案谢谢大家!这就是我一直在寻找的答案