簡體   English   中英

將代碼背后的值傳遞給JavaScript函數

[英]Pass Value from Code Behind to JavaScript Function

下面是我的JavaScript函數

function HighlightWord(highlightword) {
       alert(highlightword);
}

當我使用下面的代碼將值傳遞給上面的函數時

Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "HighlightWord(abc)", true);

警報顯示'undefined'。 這有什么問題? 謝謝。

Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "HighlightWord(abc)", true); 

意味着警告我認為你沒有的abc變量。 它應該是

Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "HighlightWord('abc')", true);`. 

這將警告“abc”,這是我認為你想要發生的事情。

暫無
暫無

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

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