• <small id='kiPHO'></small><noframes id='kiPHO'>

  • <tfoot id='kiPHO'></tfoot>

      <i id='kiPHO'><tr id='kiPHO'><dt id='kiPHO'><q id='kiPHO'><span id='kiPHO'><b id='kiPHO'><form id='kiPHO'><ins id='kiPHO'></ins><ul id='kiPHO'></ul><sub id='kiPHO'></sub></form><legend id='kiPHO'></legend><bdo id='kiPHO'><pre id='kiPHO'><center id='kiPHO'></center></pre></bdo></b><th id='kiPHO'></th></span></q></dt></tr></i><div id='kiPHO'><tfoot id='kiPHO'></tfoot><dl id='kiPHO'><fieldset id='kiPHO'></fieldset></dl></div>
    1. <legend id='kiPHO'><style id='kiPHO'><dir id='kiPHO'><q id='kiPHO'></q></dir></style></legend>
        • <bdo id='kiPHO'></bdo><ul id='kiPHO'></ul>

        为什么基本标签不适用于相对路径?

        时间:2023-07-31

                <tbody id='5IFOo'></tbody>
              <tfoot id='5IFOo'></tfoot>
              • <small id='5IFOo'></small><noframes id='5IFOo'>

              • <i id='5IFOo'><tr id='5IFOo'><dt id='5IFOo'><q id='5IFOo'><span id='5IFOo'><b id='5IFOo'><form id='5IFOo'><ins id='5IFOo'></ins><ul id='5IFOo'></ul><sub id='5IFOo'></sub></form><legend id='5IFOo'></legend><bdo id='5IFOo'><pre id='5IFOo'><center id='5IFOo'></center></pre></bdo></b><th id='5IFOo'></th></span></q></dt></tr></i><div id='5IFOo'><tfoot id='5IFOo'></tfoot><dl id='5IFOo'><fieldset id='5IFOo'></fieldset></dl></div>
                  <bdo id='5IFOo'></bdo><ul id='5IFOo'></ul>
                  <legend id='5IFOo'><style id='5IFOo'><dir id='5IFOo'><q id='5IFOo'></q></dir></style></legend>
                  本文介绍了为什么基本标签不适用于相对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在页面的 <head> 部分有一个 <base> 标记,如下所示:

                  I have a <base> tag as below in <head> section of the page:

                  <base href="http://localhost/framework">
                  

                  下面是一个相对的脚本(当然在<base>之后):

                  And a script as below which is relative (of course after <base>):

                  <script src="/assets/jquery-1.7.1.min.js">
                  

                  但是当我从 firebug 打开 jQuery 时,它显示:

                  But when I open jQuery from firebug it shows:

                  <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
                  <html><head>
                  <title>404 Not Found</title>
                  </head><body> 
                  Blah Blah Blah....
                  

                  当我使用下面的链接时没关系:

                  When I use the below link it's OK though:

                  <script src="http://localhost/framework/assets/jquery-1.7.1.min.js">  
                  

                  我到处寻找答案,但看来我的工作做得对!那么问题出在哪里?

                  I looked for an answer everywhere, but it seems I'm doing my job right! So what is the problem?

                  推荐答案

                  /assets/jquery-1.7.1.min.js 不是相对的而是绝对的*,/ 即使使用 base 标记也将其带到根目录.

                  /assets/jquery-1.7.1.min.js is not relative but absolute*, the / takes it to the root even with a base tag.

                  如果您删除该 /,它应该使其相对于当前路径,当 base 标记存在时,该路径将是 http://本地主机/框架/.

                  If you remove that /, it should make it relative off the current path, which, when a base tag is present would be http://localhost/framework/.

                  注意:您还需要在 href 的末尾添加一个尾随 /,以表明它是一个文件夹.

                  Note: You will also need to add a trailing / to the end of the href, to indicate that it's a folder.

                  完整的工作示例:

                  <!doctype html>
                  <html>
                  <head>
                  <base href="/test/" />
                  <script src="assets/test.js"></script>
                  <body>
                  hi
                  </body>
                  </html>
                  

                  * 实际上取决于你问的是谁,它仍然是相对的,因为它与当前域无关.但我更喜欢称它为绝对,因为它表示路径来自根,基于当前域.虽然,我想从技术上讲,这使得它在宏伟的计划中是相对的,而仅就当前领域而言是绝对的.随便.

                  * Actually depending on who you ask, it's still relative since it is relative off the current domain. But I prefer to call this absolute since it's signifying the path is from the root, based on the current domain. Although, I guess technically that makes it relative in the grand scheme of things, and absolute only in terms of the current domain. Whatever.

                  这篇关于为什么基本标签不适用于相对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如果浏览器不支持 HTML5 的&lt;video&gt;,我如何显示图像?标签 下一篇:我应该使用 &lt;p/&gt;标记中的标记?

                  相关文章

                  <legend id='QDvBG'><style id='QDvBG'><dir id='QDvBG'><q id='QDvBG'></q></dir></style></legend>

                  1. <tfoot id='QDvBG'></tfoot>

                    • <bdo id='QDvBG'></bdo><ul id='QDvBG'></ul>

                      <small id='QDvBG'></small><noframes id='QDvBG'>

                      <i id='QDvBG'><tr id='QDvBG'><dt id='QDvBG'><q id='QDvBG'><span id='QDvBG'><b id='QDvBG'><form id='QDvBG'><ins id='QDvBG'></ins><ul id='QDvBG'></ul><sub id='QDvBG'></sub></form><legend id='QDvBG'></legend><bdo id='QDvBG'><pre id='QDvBG'><center id='QDvBG'></center></pre></bdo></b><th id='QDvBG'></th></span></q></dt></tr></i><div id='QDvBG'><tfoot id='QDvBG'></tfoot><dl id='QDvBG'><fieldset id='QDvBG'></fieldset></dl></div>