调用javascript函数 [英] calling a javascript Function
本文介绍了调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
请帮助这个
i无法从后面的代码中调用
< script type = 文本/ JavaScript的跨度>>
function showError(msg)
{
document .getElementById(' frm2')[ 0 ]。src = msg;
}
< / script>
请帮助
解决方案
试试这个来调用你的javascript来自代码:protected void Page_Load( object sender,EventArgs e)
{
Page.ClientScript.RegisterStartupScript( this .GetType(),< span class =code-string> Call_my_function, showError('你好这是来自服务器端的消息!'), true );
}
Page.ClientScript.RegisterStartupScript( this .GetType(), alert, showError('我是男孩');, true );
在您的代码隐藏中使用以上内容它应该可以工作..
-Anurag
访问这里..
http://devlicio.us/blogs/sergio_pereira/archive/2009/02/09/javascript-5-ways -to-call-a-function.aspx [ ^ ]
或
http://msdn.microsoft.com/en-us/library/ie/h2ak8h2y(V = vs.94)的.aspx [< a href =http://msdn.microsoft.com/en-us/library/ie/h2ak8h2y(v=vs.94).aspx\"target =_ blanktitle =New Window> ^ ]
hi all
please help on this
i am unable to call it from code behind
<script type="text/javascript">
function showError(msg)
{
document.getElementById('frm2')[0].src = msg;
}
</script>
please help
解决方案
hi,
Try this to call your javascript from code behind:protected void Page_Load(object sender, EventArgs e) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Call_my_function", "showError('hello this is a message from server side!')", true); }
Page.ClientScript.RegisterStartupScript(this.GetType(),"alert","showError('I am a boy');",true);
Use the above in your code-behind and it should work..
-Anurag
Visit here..
http://devlicio.us/blogs/sergio_pereira/archive/2009/02/09/javascript-5-ways-to-call-a-function.aspx[^]
or
http://msdn.microsoft.com/en-us/library/ie/h2ak8h2y(v=vs.94).aspx[^]
这篇关于调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文