简体   繁体   English

经典 ASP 页面中的 call.js function

[英]call .js function in classic ASP page

call.js function in separate classic asp page - not working call.js function 在单独的经典 asp 页面中 - 不工作

common.js file - separate file path common.js 文件 - 单独的文件路径

file path ----- common\javascript\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;
       }
   }
}

Classic page...经典页面...

AccountsDetail.asp file path ----- Accounts\AccountsDetail.asp AccountsDetail.asp 文件路径 ----- Accounts\AccountsDetail.asp

Added js file in the在 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>

CLIFFNOTES: You forgot the <script></script> tags. CLIFFNOTES:你忘记了<script></script>标签。

If you want to use JavaScript in ASP Classic, make sure its done outside of the <% %> tags of course.如果你想在 ASP Classic 中使用 JavaScript,当然要确保它在<% %>标签之外完成。 And the code its self needs to be inside of script tags:并且其自身的代码需要在脚本标签内:

Example:例子:

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

Answer:回答:

<script>
ElseIf (sApplCode = "CLOAN") Then
Dim isBHIAttributesEnabled: isBHIAttributesEnabled = jsEnableBHIRemappingAttributes()
   
If (isBHIAttributesEnabled = True) Then
   sStylesheetFile = "commercialLoansBHI.xsl"
Else
    sStylesheetFile = "commercialLoans.xsl"
End
</script>

Although it's not entirely true, you can, against advisement however, use Response.Write to make ASP Classic write JavaScript or HTML or what not like this:尽管这并不完全正确,但是您可以不顾建议,使用Response.Write使 ASP Classic 编写 JavaScript 或 HTML 或类似的东西:

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

However, you need to make sure that if you use ( to close it with the other ) , and often times they aren't needed but helps visually with formatting the code sometimes.但是,您需要确保如果您使用(与另一个关闭它) ,并且通常不需要它们,但有时有助于在视觉上格式化代码。

And importantly , if the JavaScript code uses " double quotes in it, replace them with ' single quotes in between the " double quotes of the Response.Write and you could technically put JavaScript inside of the <% %> tags if you want to be a contrarian.重要的是,如果 JavaScript 代码在其中使用"双引号,请将它们替换为'Response.Write "双引号之间的单引号,如果您愿意,您可以在技术上将 JavaScript 放在<% %>标记内一个逆势者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM