~/相当于 javascript [英] ~/ equivalent in javascript
本文介绍了~/相当于 javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 JavaScript 中进行基于根"的路径引用的任何智能方法,就像我们在 ASP.NET 中使用 ~/
的方式一样?
Any smart way of doing a "root" based path referencing in JavaScript, just the way we have ~/
in ASP.NET?
推荐答案
让你的页面生成一个类似如下的标签:
Have your page generate a tag with something like:
<link rel="home" id="ApplicationRoot" href="http://www.example.com/appRoot/" />
然后,在 JavaScript 中使用一个函数来提取值,例如:
Then, have a function in JavaScript that extracts the value such as:
function getHome(){
return document.getElementById("ApplicationRoot").href;
}
这篇关于~/相当于 javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文