Invok Script再次调用相同的方法 [英] Invok Script calls same method again

查看:54
本文介绍了Invok Script再次调用相同的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的HTML代码

The below is my HTML code

< html>

< head>

< script>

function test()

{

return"你叫test1";

}

功能测试()

{

返回"您调用了test2";

}

<html>
<head>
<script>
function test()
{
return "you called test1";
}
function Test()
{
return "you called test2";
}

< /脚本>

< / head>

< body>

这只是一个测试html

< / body>

< / html>

我在按钮点击事件中调用了来自c#代码的methds测试和测试

i am calling the methds test and Test from c# code in a button click event as

private void button1_Click( 对象 发件人,
EventArgs e)

privatevoidbutton1_Click(objectsender, EventArgse)

{     

{    

object test = webBrowser1.Document。 InvokeScript( "测试" );

object test1 = webBrowser1.Document。 InvokeScript( " test" );

MessageBox 。显示(test.ToString ()+ test1.ToString());

MessageBox.Show(test.ToString()+test1.ToString());

}

我的预期结果是 消息框应该显示为"你叫test2you称为test1"但我是
将消息称为"你称为test2you,称为test2"。

My expected result is  the message box should show as "you called test2you called test1" but i am getting the message as "you called test2you called test2".

请帮助我。

在此先感谢:)

推荐答案

再次尝试使用不同的Test变量,比如Test1和Test2.Javascript内部区分大小写,但依赖案例敏感性一般来说是一个坏主意。完全有可能C#方法不区分大小写。

Try it again with different variables for Test, say Test1 and Test2. Javascript is case sensitive internally but relying on case sensitivity is a bad idea in general. It's entirely possible that the C# method isn't case sensitive.


这篇关于Invok Script再次调用相同的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆