举个例子来说明这个问题。
假如我们有如下文件目录树:(\是文件夹)
–\site
——\images
———index_02.jpg
——test.htm
–\css
——\css
———-test.css
–\js
——\js
———-test.js
引用代码如下:
test.css
复制代码
代码如下:
#imgtest
{
background-image:url(../../site/images/index_02.jpg);
width:500px;
height:50px;
border:solid 1px red;
}
test.js
function writeimg()
{
document.write(“<img src=’images/index_02.jpg’ />”);
}
test.htm
复制代码
代码如下:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” >
<head>
<title>test</title>
<script type=”text/javascript” src=”../js/js/test.js”></script>
<link href=”../css/css/test.css” rel=”stylesheet” type=”text/css” />
</head>
<body>
<script type=”text/javascript”>
writeimg();
</script>
<div id=”imgtest”></div>
</body>
</html>