简体   繁体   English

Windows Phone 8的javascript用户名密码https登录问题

[英]javascript username password https login issue for windows phone 8

I am a newbie coming from IOS and Android and trying to replicate a feature in those apps where I use a username and password that is saved in preferences (isolatedstorage) and inject it into the javascript of the https web page. 我是来自IOS和Android的新手,并尝试在这些应用程序中复制功能,在这些应用程序中,我使用保存在首选项(隔离存储)中的用户名和密码并将其注入到https网页的javascript中。 From a previous question I asked before I now understand that I can not use System.Windows.Forms as that is for W8Desktop and I am targeting windows phone 8. 之前我问过的一个问题开始,我现在才知道我不能使用System.Windows.Forms,因为它是针对W8Desktop的,并且我的目标是Windows Phone 8。

In android I did the following: 在android中,我执行了以下操作:

view.loadUrl(“javascript:document.getElementById(‘Login1_UserName’).value=’”+userName+”‘;javascript:document.getElementById(‘Login1_Password’).value = ‘”+password+”‘;”);
view.loadUrl(“javascript:document.getElementById(‘Login1_LoginButton’).click();”);

and I am trying to do it in Visual Studio 2012 but its not working. 我正在尝试在Visual Studio 2012中执行此操作,但无法正常工作。 Here is my code: 这是我的代码:

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();”});

But it just wont work. 但这只是行不通的。 So my questions are two: 所以我的问题是两个:

  1. If I want to create a small script I assume that is called eval, do I add a resource file to my project or add it as a block of code in my mainpage.xaml.cs? 如果我想创建一个小脚本(假定为eval),是否将资源文件添加到项目中,或将其作为代码块添加到mainpage.xaml.cs中? If so how? 如果可以,怎么办?
  2. If I do as above, is there an issue with my syntax? 如果我按上述方式进行操作,语法是否存在问题?

Many thanks for any pointers you may be able to give to help. 非常感谢您可以提供帮助的任何指示。

I have a solution now, but still need to know how to implement it. 我现在有一个解决方案,但仍然需要知道如何实现。

Here is the correct code to inject javascript into the form. 这是将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();"));

The issue I had was that I was not allowing the page to finish loading before running the script. 我遇到的问题是,在运行脚本之前,我不允许页面完成加载。 I have tried a few things but to no aval so I will keep digging and edit once I have it solved. 我已经尝试了一些方法,但没有尝试过,因此一旦解决,我将继续进行挖掘和编辑。

Hope this helps someone else. 希望这对其他人有帮助。

JUST REMEMBER YOU CAN NOT USE browser.document as you see in some solutions as it wont work on windows phone. 请记住,您不能使用在某些解决方案中看到的browser.document,因为它将无法在Windows Phone上使用。 Happy to be corrected as I am a newbie, but that trail cost me too many hours. 我是新手,很高兴得到纠正,但是那条路花了我太多时间。 You need to use Invokescript for windows phone code. 您需要将Invokescript用于Windows Phone代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用户名和密码数据Windows Phone 8应用 - Username and Password data Windows phone 8 app 在Windows Phone和商店应用中测试的用户名/密码 - Username/Password for testing in windows phone and store apps 如何在Windows Phone 8中通过HTTPS发布请求登录? - How to login in by HTTPS post request in windows phone 8? POST asp.net表单用户名和密码以外部HTTPS登录 - POST asp.net form username and password to an external HTTPS login 如何使用 Windows 登录的用户名和密码访问 Outlook Exchange Server? - How to access Outlook Exchange Server with Username and Password from Windows Login? 在树莓派上使用Windows 10 IoT的Gmail中的登录用户名和密码 - Login username and password in Gmail with Windows 10 iot on raspberry Pi C#使用Windows应用程序将用户名/密码发布到登录页面 - C# post username/password to the login page using windows application IdentityServer 4 使用用户名或电话号码登录 - IdentityServer 4 login with username or phone number Windows Phone 8.1 Live SDK 5.6登录问题 - Windows Phone 8.1 Live SDK 5.6 Login issue WCF:将用户名和密码传递给另一个服务(无Https) - WCF: Passing Username and password to another service (No Https)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM