在我的项目中,我遇到了href的问题。
我的html页面是a.php,其代码是:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="http://www.ulpin.com /css/bootstrap.min.css">
<style>
dd{word-wrap:break-word;};
</style>
<title>SystemTitle</title>
<script type="text/javascript" src="static/js/jquery-1.7.2-min.js"> </script>
<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
<base target="_self"/>
</head>
<body>
<br/>
<br/>
<br/>
<br/>
<div class="container">
<center>
<a href="active.php" class="btn">ManTest</a><br/><br/>
</center>
</div>
</body>
</html>
但它失败了。所以我用firefox检查了页面源代码,当我点击static / js / jquery-1.7.2-min.js的href时,显示:
Not Found
The requested URL /o1ws1v/web/admin/static/js/jquery-1.7.2-min.js was not found on this server.
src已更改。 &#34; / o1ws1v /网络/管理/&#34;添加自动。
为什么呢?
我的折叠结构是:
/yjdata/www/www/o1ws1v/web/admin/a.php
/yjdata/www/www/o1ws1v/web/static/js/jquery-1.7.2-min.js
/yjdata/www/www/o1ws1v/web/static/js/bootstrap.min.js
否则,a.php放在/ yjdata / www / www / o1ws1v / web /中,运行正常
谁能帮帮我?
答案 0 :(得分:1)
这是一个简单的路径问题。
当你在/yjdata/www/www/o1ws1v/web/admin/a.php
下并使用src="static/js/jquery-1.7.2-min.js"
时,就会发生这种情况:
--/yjdata/www/www/o1ws1v/web/admin/
| |--- a.php <-- You are here
| |--- static/ <-- This is where the browser think that the static folder exists
|--- static/ <-- This is where the folder really is !
那么,你需要在a.php
中做的是在src路径中上升一级:
<script type="text/javascript" src="../static/js/jquery-1.7.2-min.js"> </script>
..
表示父目录。