简体   繁体   English

从Windows Phone 7 / Silverlight调用Javascript函数

[英]Call Javascript function from Windows Phone 7/Silverlight

I want to authenticate to a an external web page from my windows phone application. 我想从Windows Phone应用程序对外部网页进行身份验证。 I will then want to do further scraping of pages on the site but need to get past the authentication issue. 然后,我将要进一步刮取网站上的页面,但需要克服身份验证问题。

The page on the external website has a function call validateLogin which takes login name and password. 外部网站上的页面具有一个调用validateLogin的功能,该功能使用登录名和密码。

I want to call this function from my Windows Phone code passing in the required arguments. 我想通过传递所需参数的Windows Phone代码来调用此函数。 This would facilitate logging into the site and hopefully I can continue to scrape the pages. 这将有助于登录该网站,并希望我可以继续抓取这些页面。

Use the WebBrowser control and call the InvokeScript method. 使用WebBrowser控件并调用InvokeScript方法。 Ensure that you set IsScriptEnabled on the WebBrowser control and that you specify the ID_CAP_WEBBROWSERCOMPONENT capability in WMAppManifest.xml. 确保在WebBrowser控件上设置IsScriptEnabled ,并在WMAppManifest.xml中指定ID_CAP_WEBBROWSERCOMPONENT功能。

As a side note: Scraping web pages is rarely a robust and reliable approach of creating an application that uses a website :) 附带说明:抓取网页很少是创建使用网站的应用程序的可靠而可靠的方法:)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM