如何在Application.cfc的onRequestStart()中包含JavaScript

Mit*_*ali 1 html javascript coldfusion application.cfc

我有onRequestStart()如下

<cffunction name="onRequestStart" access="public" returntype="boolean" output="false" hint="initializes the request">
    <cfif deployment.DBFlag eq 'Live' >
        <cfset REQUEST.DataSource = deployment.LiveDSN>
    <cfelse>
        <cfset REQUEST.DataSource = deployment.TestDSN>
    </cfif>
    <cfset REQUEST.ServerBasePath = deployment.ServerBasePath>
    <cfif not listContains(APPLICATION.ListOfFile,Trim(cgi.script_name))>
        <cfif not isDefined("SESSION.UID")>
            <cflogout>
            <cflocation url="/rpnet-ROI/loginform.cfm" addtoken="no">
        </cfif>
    </cfif>

    <!--- Return true so the page can process. --->
    <cfreturn true />
</cffunction>
Run Code Online (Sandbox Code Playgroud)

一旦未定义会话ID,我需要重新加载我的页面.是否可以在Application.cfc中包含javascript?如果是,我们怎么做呢?我们需要包含一个包含javascript代码的cfm文件.

我需要包含在JavaScript中的代码是:

<script>parent.location.reload(true);</script>
Run Code Online (Sandbox Code Playgroud)

Sco*_*roz 5

不,不可能在Application.cfc中包含JavaScript.Application.cfc方法中的代码出现在服务器端,无法在客户端调用代码.具体来说,onRequestStart()一旦向服务器发出请求就运行.此时服务器没有响应,因此客户端无法显示/操作.