Take path from application root in javascript

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 */
    }

I wrote a javascript function loadPage () that needs a path to some page as a parameter. I need to pass this path from the root of the application. I do not need a relative path. Please let me know how I can do this.

+5
source share
4 answers

The answers to this similar question describe several different ways.

How to extract part of hostname url in javascript

+4
source

I have this piece of Javascript in my Site.master, right under the jquery import and above any link to my own scripts.

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

, "/" "" ().

:

$.url('Infringement/TaskDetail')
+6

, : http://sub.domain.com/page.htm. :

  • window.location.host: sub.domain.com:8080 sub.domain.com:80
  • window.location.hostname: sub.domain.com
  • window.location.protocol: http:
  • window.location.port: 8080 80
  • window.location.origin: http://sub.domain.com
+1

, , root . IIS, , , http://www.domain.com/iis/youapp/pages/one.aspx

+1

All Articles