想象一个网站位于http://example.com/myWebsite/。
我希望我的绝对路径指向myWebsite目录。
我知道可以对带有base标签的相对链接执行此操作,但我希望保留相对链接的默认行为。
我可以在 head 中指定一些有用的东西吗?
小智 2
<!DOCTYPE html>
<html>
<head>
<base href="http://example.com/myWebsite/" target="_blank">
</head>
<body>
<p><img src="stickman.gif" width="24" height="39" alt="Stickman"> -
Notice that we have only specified a relative address for the image.
Since we have specified a base URL in the head section, the browser will
look for the image at "http://example.com/myWebsite/stickman.gif".
</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
用这个
| 归档时间: |
|
| 查看次数: |
2411 次 |
| 最近记录: |