从Javascript解析相对URL(对于ASP.NET)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从Javascript解析相对URL(对于ASP.NET)相关的知识,希望对你有一定的参考价值。

  1. Url = function() { }
  2.  
  3. Url.prototype =
  4. {
  5. _relativeRoot: '<%= ResolveUrl("~/") %>',
  6.  
  7. resolve: function(relative) {
  8. var resolved = relative;
  9. if (relative[0] == '~') resolved = this._relativeRoot + relative.substring(2);
  10. return resolved;
  11. }
  12. }
  13.  
  14. $Url = new Url();
  15.  
  16.  
  17. //Now, anywhere I need to resolve a relative url in a script, I can do this:
  18. var logoUrl = $Url.resolve("~/Images/logo.png");

以上是关于从Javascript解析相对URL(对于ASP.NET)的主要内容,如果未能解决你的问题,请参考以下文章