使用相对·路径·,html在D:\jw_ks\nginx-1.21.6\home\it\digital_media\digital_media.html,js在D:\jw_ks\nginx-1.21.6\home\js\temp.js,那html中script怎么写
时间: 2023-09-07 17:13:14 浏览: 40
你可以使用相对路径的方式,在HTML文件中的script标签中引用temp.js文件,如下所示:
```html
<!DOCTYPE html>
<html>
<head>
<title>Digital Media</title>
</head>
<body>
<!-- 在这里引用temp.js文件 -->
<script src="../js/temp.js"></script>
</body>
</html>
```
注意,需要使用`../`表示上一级目录,因为js文件在html文件所在的上一级目录中。
相关问题
ngixn.exe在D:\jw_ks\nginx-1.21.6,先把D:\jw_ks\nginx-1.21.6\home\it\it_home.html设置为8081端口,在conf文件中怎么定义位置,并且如何输入访问地址
您好,欢迎和我进行对话!
关于您的问题,首先您需要在 nginx.conf 文件中找到 server 配置块,然后在该块中添加以下内容:
```
location / {
root D:\jw_ks\nginx-1.21.6\home\it;
index it_home.html;
}
server {
listen 8081;
server_name localhost;
location / {
root D:\jw_ks\nginx-1.21.6\home\it;
index it_home.html;
}
}
```
这段代码中,我们在 server 配置块中定义了 location,表示访问根路径时,默认使用 D:\jw_ks\nginx-1.21.6\home\it 目录下的 it_home.html 文件作为首页。同时,我们又定义了一个 server 配置块,监听 8081 端口,使得我们可以通过访问 http://localhost:8081 来访问该文件。
希望我的回答能够帮到您,如果您还有其他问题,请随时提出。
使用觉得路径·,html在D:\jw_ks\nginx-1.21.6\home\it\digital_media\digital_media.html,js在D:\jw_ks\nginx-1.21.6\home\js\temp.js,那html中script怎么写
?感谢您的提问。如果您的 js 文件在 D:\jw_ks\nginx-1.21.6\home\js\temp.js 中,那么您可以在 html 文件中使用以下代码来引用 js 文件:
```
<script src="../js/temp.js"></script>
```
其中,".." 表示返回上层目录,因为 js 文件和 html 文件在不同的目录中,所以需要使用相对路径来引用 js 文件。希望能对您有所帮助。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)