在经典的ASP页面中调用.js函数



在单独的经典asp页面中调用.js函数-不工作

common.js文件-单独的文件路径

文件路径-----common\javascript\common\.js

function jsEnableBHIRemappingAttributes() { 
if (enableBHIattributes != null) {
var oOldFormat = enableBHIattributes.selectSingleNode("/return/data/EnableBHIRemappingAttributes");
if (oOldFormat != null && oOldFormat.text.toLowerCase() == "y") {
return true;
}
else {
return false;
}
}
}

经典页面。。。

帐户详细信息.asp文件路径-----Accounts\AccountsDetail.asp

在中添加了js文件

<head>
<script language="Javascript" src="../common/javascript/common.js"></script>
</head>
<body>
ElseIf (sApplCode = "CLOAN") Then
Dim isBHIAttributesEnabled: isBHIAttributesEnabled = jsEnableBHIRemappingAttributes()

If (isBHIAttributesEnabled = True) Then
sStylesheetFile = "commercialLoansBHI.xsl"
Else
sStylesheetFile = "commercialLoans.xsl"
End
</body>

cliff注意:您忘记了<script></script>标记。

如果您想在ASP Classic中使用JavaScript,请确保它在<% %>标记之外完成。代码本身需要在脚本标签中:

示例:

<body>
<% some asp code %>
<script> ..JavaScript.. </script>
<% more asp code %>
</body>

答案:

<script>
ElseIf (sApplCode = "CLOAN") Then
Dim isBHIAttributesEnabled: isBHIAttributesEnabled = jsEnableBHIRemappingAttributes()

If (isBHIAttributesEnabled = True) Then
sStylesheetFile = "commercialLoansBHI.xsl"
Else
sStylesheetFile = "commercialLoans.xsl"
End
</script>

尽管这并不完全正确,但您可以使用Response.Write让ASP Classic编写JavaScript或HTML或类似的东西:

Response.Write("<script> javascript </script>")

但是,您需要确保,如果使用(与其他)来关闭它,并且通常不需要它们,但有时有助于可视化地格式化代码。

重要的是,如果JavaScript代码中使用"双引号,请将其替换为Response.Write"双引号之间的'单引号,如果您想成为反向者,可以从技术上将JavaScript放入<% %>标记中。

最新更新