<a href="page.html&gt; and &lt;a href=" page.php="">: do these both trigger an interaction with the web server?

时间:2017-04-21 09:48:53

标签: php html

I have to solve this problem:

Explain what the following code snapshots do, and for each specify
whether it triggers an interaction (of the client/browser) with the server or
it is executed at the client side.  

    (iv) <a href="page.html">click here</a>  
    (v) <a href="page.php">click here</a>

Now, respectively they call for page.html and page.php from the web server. My instinct says this counts as an interaction (request-receive) of the client with the server in both cases, but the way the question is laid out seems to suggest that perhaps only the php link truly counts as an interaction.

Could anyone confirm the correct interpretation and perhaps clarify what counts as an interaction with the server.

2 个答案:

答案 0 :(得分:1)

正如你的直觉所说,两者都会触发与服务器的交互 在不知道服务器设置的情况下,您甚至不知道HTML文件是否未经修改地提供,或者是否正在通过任何服务器端脚本语言重写和处理请求。

问题明确说明另一个选项是在客户端执行,这对两者来说都是错误的。唯一的例外是截取click事件,但是在客户端需要更多代码,而这必须是问题的一部分。

答案 1 :(得分:0)

代码本身不进行服务器交互。浏览器使用此代码绘制超链接,仍然没有服务器交互。一旦用户单击任何链接,就会触发浏览器和服务器之间的交互(无论是.html还是.php,服务器都会收到请求并决定如何处理它)

如果页面在本地以file://C:/.../xxx.html打开,它会直接与本地主机进行交互,我不知道这是否被视为服务器交互...这个问题对我来说似乎有点不清楚。 / p>