Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# windows phone 8的javascript用户名密码https登录问题_C#_Visual Studio 2012_Windows Phone 8 - Fatal编程技术网

C# windows phone 8的javascript用户名密码https登录问题

C# windows phone 8的javascript用户名密码https登录问题,c#,visual-studio-2012,windows-phone-8,C#,Visual Studio 2012,Windows Phone 8,我是一名来自IOS和Android的新手,尝试在这些应用程序中复制一项功能,我使用保存在首选项(isolatedstorage)中的用户名和密码,并将其注入https网页的javascript中。从一开始,我现在了解到我不能使用System.Windows.Forms,因为这是用于W8Desktop的,我的目标是Windows phone 8 在安卓系统中,我做了以下工作: view.loadUrl(“javascript:document.getElementById(‘Login1_User

我是一名来自IOS和Android的新手,尝试在这些应用程序中复制一项功能,我使用保存在首选项(isolatedstorage)中的用户名和密码,并将其注入https网页的javascript中。从一开始,我现在了解到我不能使用System.Windows.Forms,因为这是用于W8Desktop的,我的目标是Windows phone 8

在安卓系统中,我做了以下工作:

view.loadUrl(“javascript:document.getElementById(‘Login1_UserName’).value=’”+userName+”‘;javascript:document.getElementById(‘Login1_Password’).value = ‘”+password+”‘;”);
view.loadUrl(“javascript:document.getElementById(‘Login1_LoginButton’).click();”);
我正试图在VisualStudio2012中实现它,但它不起作用。这是我的密码:

Browser.Navigate(new Uri(mainUrl, UriKind.Absolute));

Browser.InvokeScript(“eval”, new string[] { “document.getElementById(‘Login1_UserName’).value = ‘”+username+”‘ , document.getElementById(‘Login1_Password’).value = ‘”+password+”‘;”});
Browser.InvokeScript(“eval”, new string[] { “document.getElementById(‘Login1_LoginButton’).click();”});
但它就是不起作用。所以我的问题有两个:

  • 如果我想创建一个名为eval的小脚本,我应该向项目中添加一个资源文件,还是将其作为代码块添加到mainpage.xaml.cs中?如果是,怎么做
  • 如果我像上面那样做,我的语法有问题吗

  • 非常感谢您提供的帮助。

    我现在有了一个解决方案,但仍然需要知道如何实现它

    下面是将javascript注入表单的正确代码

     browser.InvokeScript("eval", "document.getElementById('Login1_UserName').value = '" + username + "';");
     browser.InvokeScript("eval", ("document.getElementById('Login1_Password').value = '" + password + "';"));
     browser.InvokeScript("eval", string.Format("document.getElementById('Login1_LoginButton').click();"));
    
    我遇到的问题是,我不允许页面在运行脚本之前完成加载。我已经尝试了一些事情,但没有成功,所以我会继续挖掘和编辑,一旦我解决了它

    希望这对其他人有帮助


    请记住,在某些解决方案中,您不能使用browser.document,因为它在windows phone上不起作用。很高兴被纠正,因为我是一个新手,但这条路花了我太多的时间。您需要使用Invokescript for windows phone代码。

    大家好,仍然需要解决这个问题,以防有人通过这个问题,并且知道我做得不正确。好的,我已经检查了webbrowser的所有可能方法,每次我尝试加载页面,然后在注入javascript之前等待加载,我犯了一个错误。因此,在与服务器chap交谈之后,我们将对其进行修改,并使用用户名和密码发布帖子。但是,如果您只需要在已经加载的页面上注入javascript,那么这肯定会起作用。