簡體   English   中英

經典 ASP 頁面中的 call.js function

[英]call .js function in classic ASP page

call.js function 在單獨的經典 asp 頁面中 - 不工作

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;
       }
   }
}

經典頁面...

AccountsDetail.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>

CLIFFNOTES:你忘記了<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 放在<% %>標記內一個逆勢者。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM