~/ equivalent in javascript

后端 未结 12 1984
萌比男神i
萌比男神i 2020-12-12 19:11

Any smart way of doing a \"root\" based path referencing in JavaScript, just the way we have ~/ in ASP.NET?

12条回答
  •  心在旅途
    2020-12-12 20:04

    Have your page generate a tag with something like:

    
    

    Then, have a function in JavaScript that extracts the value such as:

    function getHome(){
        return document.getElementById("ApplicationRoot").href;
    }
    

提交回复
热议问题