English 中文(简体)
call、 j卷宗的最佳方式?
原标题:Best way to call css, js files?
  • 时间:2011-11-21 08:04:19
  •  标签:
  • php
  • html
  • css

假设贵领域为domain.com,并附上以下目录和档案:

- index.php
<panel>
- panel.php
<css>
- style.css
<js>
- jQuery.js

In index.php you may call a css file like "css/style.css" or "domain.com/css/style.css"
In panel.php you may call a js file like "../js/jQuery.js" or "domain.com/js/jQuery.js"

What is the best method to use? css/style.css or domain.com/css/style.css ?
Does it make any difference? I am asking because in my case it will help me to use the domain.com/css/style.css but is it treated as an external file that may reduce perfomance?

最佳回答

you can even include all sources with //. means

<script src="//js/jquery.js"></script

the Browser takes http or https automaticly. So the Source can be included for both Ports without any Errors

问题回答

cs/上型.css将对照您的目前情况,与您的相联。 如果你被列入原来的指数.php,就会工作。 如果你在<条码>/代号/某页>.php上,则不会奏效,因为它将试图从<条码>/代号/文件/风格.css上获取你的文件。

domain.com/css/type.cs将始终有效,但前提是您不改变域名。

www.un.org/Depts/DGACM/index_chinese.htm

也可以使用:

/css/style.css 

这是一条绝对的道路,但在同一领域。

只要在前面没有<条码>http://,就应当作为双倍处理。

Does it make any difference?

是的,主要涉及可维持性。 如果卷宗一移到你,则需要重新列出<>有关链接的所有参考资料(例如,./js/jQuery.js),而则可以更改(例如,:-或单纯的

我之所以问,是因为在我的案件中,它将帮助我使用domain.com/cs/e.cs,但是否把它作为可能减少持久性的外部档案处理?

无,只要东道方相同,客户(浏览器)就应当将其视为“当地”联系(但不应直接影响到业绩)。

通常,我用一条如<条码>/css/上型.css的一条固态道路。

因此,你不必担心在一段时间内改变域名(如把dev子转移到生产)或从哪里传来(指数.php,/panel/panel.php)。

如果您转向<代码>https,也可确保不列入礼宾计划(如http://)。 例如,浏览器会声称一些不安全的内容。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签