为什么不起作用?(Why does not work?)

编程入门 行业动态 更新时间:2024-10-28 06:34:06
为什么<! - #include file =“top.shtml” - >不起作用?(Why does not work?)

我不明白为什么命令在下面的情况下不起作用。

代码中列出的文件与包含.html代码的文件位于同一目录中,但我想要包含的文件将不会加载(至少在我在Chrome中打开文件时不会加载)。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <link href="helper.css" media="screen" rel="stylesheet" type="text/css"> <link href="dropdown.vertical.css" media="screen" rel="stylesheet" type="text/css"> <link href="default.css" media="screen" rel="stylesheet" type="text/css"> <body> <!--#include file="top.shtml"--> <!--#include file="sidemenu.shtml"--> <h1> Name </h1> <h2>Title </h2> </body> </html>

我读到我要加载的文件应该更改为我所做的.shtml文件,但它似乎没有用。 这里有点新手所以我可能只是不理解某些东西。 一个问题是,如果它正常工作,如果我在谷歌浏览器中打开文件,我是否应该看到它有效,或者它实际上是否必须在服务器上作为代码才能工作的网页?

I don't understand why the command does not work in the case below.

The files listed in the code are all in the same directory as the file containing the .html code, but the files I want to include will not load (at least not when I open the file in Chrome).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <link href="helper.css" media="screen" rel="stylesheet" type="text/css"> <link href="dropdown.vertical.css" media="screen" rel="stylesheet" type="text/css"> <link href="default.css" media="screen" rel="stylesheet" type="text/css"> <body> <!--#include file="top.shtml"--> <!--#include file="sidemenu.shtml"--> <h1> Name </h1> <h2>Title </h2> </body> </html>

I read that the files that I want to load should be changed to .shtml files which I did, but it did not seem to work. Something of a novice here so I might just not be understanding something. One question is, if it is working, should I see it working if I open the file in Google Chrome, or does it actually have to be on a server as a web page for the code to work?

最满意答案

服务器端脚本语言(如SSI (您在代码中使用)以及PHP和ASP等等都在服务器上执行。 “Chrome”只是一个网络浏览器,并不执行服务器端指令。

下面是它的工作原理:

您将资源请求发送到服务器(在您的情况下, SHTML文件的请求可以通过在浏览器的地址栏中输入URI), 服务器获取请求并执行一些过程,例如执行指定的指令(如在您的情况下,执行#include指令), 最后,服务器将响应(在您的情况下作为HTML文件)返回给客户端 - 即Web浏览器 - 进行呈现。

Server-side scripting languages like SSI -- which you used in your code -- and PHP and ASP and many more are all executed on the server. "Chrome" is just a web browser, and doesn't carry out the server side instructions.

Here is how it works:

You send the request for a resource to the server (as in your case, the request for the SHTML file can be through entering the URI in the address bar of your browser), The server gets the request and goes through some processes like carrying out the specified instructions (as in your case, executing the #include directives), And finally, the server returns the response (in your case as a HTML file) back to the client -- i.e. the web browser -- to be presented.

更多推荐

本文发布于:2023-07-06 20:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1054512.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   work

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!