如何设置文件的路径在网站根用jquery使用? [英] How to set path of file in website root for use by jquery?
问题描述
我使用jquery-style-switcher.js来改变一些元素的样式。在这种情况下,我必须在根网站中指定样式表文件的完整路径。在此页面的页面源中,另一个css文件具有链接这:
I use jquery-style-switcher.js for change style some of elements.In this case i must specify the full path of style sheet files in root website.In the page source of this page another css files has link such as this:
/dnn_test/Portals/_default/Skins/Crew/css/style.css
我使用这个完整路径作为切换器
and I use this full path for switcher
fullPath: '/DNN_test/Portals/_default/Skins/Crew/css/'
推荐答案
window.location code> object具有以下属性:
The window.location
object has the following properties :
考虑示例引用:
document.referrer;
"http://stackoverflow.com/questions/2668005/jquery-get-url-path#footer"
location:{
hash: "#footer"
host: "stackoverflow.com"
hostname: "stackoverflow.com"
href: "http://stackoverflow.com/questions/2668005/jquery-get-url-path#footer"
origin: "http://stackoverflow.com"
pathname: "/questions/2668005/jquery-get-url-path"
port: ""
protocol: "http:"
}
您可以使用位置.pathname
,并且空的默认http端口为80
You can use location.pathname
, and the empty default http port is 80
对于jQuery使用:
For jquery use :
Tyr从'/ DNN_test / Portals / _default / Skins / Crew / css /'
中删除 /
它将如下所示:
Tyr to remove /
from the '/DNN_test/Portals/_default/Skins/Crew/css/'
so it will look like:
DNN_test/Portals/_default/Skins/Crew/css/
这篇关于如何设置文件的路径在网站根用jquery使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!