2013-10-27 29 views
0

下面是我的JavaScript功能通過值從代碼後面的JavaScript功能

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

當我使用下面的代碼

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

警報顯示「未定義」傳遞價值,以上述功能。這有什麼問題?謝謝。

回答

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

意味着提醒abc變量,我假設你沒有。它應該是

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

這將提醒「abc」,這是我認爲你想要發生的事情。