是HTML< base>标签也受到脚本和CSS的尊重? [英] Is the HTML <base> tag also honored by scripting and CSS?

查看:157
本文介绍了是HTML< base>标签也受到脚本和CSS的尊重?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基础 HTML元素为HTML中的相对URI提供了基础。 JavaScript和CSS也必须遵守它们在其中发布的相对URI:

The base HTML element provides a base for relative URIs in the HTML. Must JavaScript and CSS also honor it for relative URIs issued in them:

例如。

JavaScript:

JavaScript:

location.href = "mypage.htm"` 

CSS:

h4 { 
    background-image: url(myimage.gif) 
}


CSS路径总是(除了当IE6是buggy和愚蠢的时候),并且(在任何浏览器?)

(in any browser?)

推荐答案

尝试加载与相对于样式表本身的CSS 行为属性相关的 .htc 文件,依赖于HTML位置。对于其他东西,< base> 将影响感知的HTML的当前目录,就像文件位于由base定义的目录中。因此,它会影响 location.href = ...; 。顺便说一下,相对于文档位置加载< style> 元素中的内联样式和样式信息。当然,这些都受到< base> 标记的影响。

CSS paths are always (except when IE6 is buggy and stupid and tries to load .htc files specified in CSS behavior attributes relative to the document) relative to the stylesheet itself and have no dependence on the HTML location. For other stuff, <base> will affect the perceived current directory of the HTML as if the file was located in the directory defined by base. Consequently, it does affect things like location.href=...;. By the way, inline styles and style information in <style> element are loaded relative to the document location. Those are affected by the <base> tag, of course.

这篇关于是HTML&lt; base&gt;标签也受到脚本和CSS的尊重?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆