是否以"render to html"执行的请求中的javascript代码?阶段 [英] whether javascript codes in a request, executed in "render to html" stage

查看:56
本文介绍了是否以"render to html"执行的请求中的javascript代码?阶段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请求中的javascript代码是否在渲染为html"阶段请求生命周期中执行?或者不是?

whether javascript codes in a request, executed in "render to html" stage request Life cycle?or not?

推荐答案

答案很简单:不! 页面生命周期中的HTML呈现是在服务器端上执行的操作.因此,作为HTML一部分的javascript也将呈现给响应.服务器总是以某种响应来响应请求,并且当响应为HTML时,将在响应标头中设置正确的mime类型,并且所述响应的主体包含HTML(如前所述),HTML也可以直接包含一些javascript.在HTML正文中或通过脚本标签链接到包含该javascript的某些源.
正因为如此,执行JavaScript的唯一机会是客户端直接通过用户页面请求或通过Ajax调用间接接收到了它.

希望我能解决一下这个问题.

最好的问候,

-MRB
Answer is plain and simple: No! The rendering of HTML in the page life cycle is an action that is performed on the server side. The javascript being part of the HTML is thus also rendered to the response. The server always answers to a request with some kind of response and when the response is HTML the correct mime type is set in the response headers and the body of said response contains the HTML which, as already noted, can also contain some javascript either directly inside the HTML body or linked via script tag to some source containing that javascript.
Be that as it may the only chance for the javascript to get executed is when it has been received by the client either directly by a user page request or indirectly via an Ajax call.

Hope I could clear that issue up a little.

Best regards,

-MRB


这篇关于是否以"render to html"执行的请求中的javascript代码?阶段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆