function detailed_link(cell_rowid) {
var $tabs = $('#infrTab').tabs();
$tabs.tabs('select', 1); // switch to third tab~
objRowData = $('#' + pageGridId).getRowData(cell_rowid);
//document.getElementById("Name").value = objRowData.amount;
loadPage('Infringement/TaskDetail', 'taskDetails'); /* Path */
}我写了一个javascript函数loadPage(),它需要一个指向某个页面的路径作为参数。我需要提供从应用程序根目录开始的路径。我不想要相对路径。请让我知道我该怎么做。
发布于 2010-09-07 13:14:39
我的Site.master中有这段Javascript,就在jquery import的下面,以及对我自己的脚本的引用之上。
<script type="text/javascript">
//Function that provides a relative URL for cases of virtual directories.
jQuery.url = function (path) {
return '<%: Url.Action("Index","Home") %>' + path;
};
</script>这假设您的'/‘地址是由您的Home控制器(标准)中的Index方法处理的。
然后,您可以通过以下方式访问它:
$.url('Infringement/TaskDetail')发布于 2013-06-27 15:00:47
假设您有一个具有以下地址的页面:http://sub.domain.com/page.htm。在页面代码中使用以下代码来实现这些结果:
window.location.host:你会得到sub.domain.comwindow.location.protocol:你会得到http:window.location.port:你会得到80window.location.origin:你会得到http://sub.domain.com:你会得到sub.domain.com:8080或8080
发布于 2014-09-16 14:35:27
我建议使用相对路径,因为您永远不知道应用程序根目录在哪里。如果您的应用程序将与IIS中的其他应用程序一起安装,则其根可以是例如http://www.domain.com/iis/youapp/pages/one.aspx
https://stackoverflow.com/questions/3655868
复制相似问题