小编byr*_*ron的帖子

UIWebView是否可以保存并自动填充以前输入的表单值(例如,用户名和密码)?

我正在构建一个iPhone应用程序,它只是一个UIWebView具有基于表单的登录的现有移动网站.当我在iPhone Safari上登录移动网站时,系统会提示我保存用户名/密码,然后当我稍后返回该网站时自动填充.

我想启用相同的功能UIWebView,但对于我的生活,我无法弄清楚如何做到这一点.有任何想法吗?


按照Michael的基本模型(参见接受的答案),我能够完成这项工作.这是我做的:

设置数据

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; {

    //save form data
    if(navigationType == UIWebViewNavigationTypeFormSubmitted) {

        //grab the data from the page
        NSString *username = [self.webView stringByEvaluatingJavaScriptFromString: @"document.myForm.username.value"];
        NSString *password = [self.webView stringByEvaluatingJavaScriptFromString: @"document.myForm.password.value"];

        //store values locally
        [[NSUserDefaults standardUserDefaults] setObject:username forKey:@"username"];
        [SFHFKeychainUtils storeUsername:username andPassword:password forServiceName:@"MyService" updateExisting:YES error:nil];

    }    

}
Run Code Online (Sandbox Code Playgroud)

获取数据

- (void)webViewDidFinishLoad:(UIWebView *)webView{

    //verify view is on the login page of the site (simplified)
    NSURL *requestURL = [self.webView.request URL];
    if ([requestURL.host isEqualToString:@"www.mydomain.com"]) …
Run Code Online (Sandbox Code Playgroud)

forms iphone autofill uiwebview

34
推荐指数
1
解决办法
1万
查看次数

在同一个表中使用SUM的MySql UPDATE

我正在使用具有以下结构的表(结果)(不要问,我没有构建它)

id | record_type | user_id | answer_id | choice | score | total |    email
-------------------------------------------------------------------------------
1    email         xxxxxxx                                  0     userX@site.com
2    answer        xxxxxxx    aaaaaa       A       0
3    answer        xxxxxxx    bbbbbb       A       0
4    answer        xxxxxxx    cccccc       B       10
5    email         yyyyyyy                                  0     userY@site.com
6    answer        yyyyyyy    aaaaaa       A       0
7    answer        yyyyyyy    bbbbbb       A       0
8    answer        yyyyyyy    cccccc       A       0
9    email         zzzzzzz                                  0     userZ@site.com
10   answer        zzzzzzz    aaaaaa       A       0
11   answer        zzzzzzz    bbbbbb       A       0 …
Run Code Online (Sandbox Code Playgroud)

mysql sql sum

6
推荐指数
1
解决办法
2万
查看次数

Android WebView中禁用HTML <select>控件(在模拟器中)

我有一个非常简单的Android应用程序,它只是一个WebView.一切正常(复杂的Javascript等).但是,select似乎禁用了所有HTML 控件.它们显示默认值,但是当我点击它们时没有任何反应,当我浏览控件时它们没有得到橙色突出显示.

其他输入(文本,无线电,提交)工作正常,所以我不认为这是一个焦点问题.

组态:

  • Eclipse IDE
  • SDK版本8(2.2)
  • 在模拟器中进行测试

android html-select webview android-emulator

5
推荐指数
1
解决办法
4932
查看次数

是否可以将事件与Google Analytics中的广告系列相关联(通用)

我们正在使用活动来跟踪广告系列元素(轮播图片,侧边栏广告和页脚横幅)的展示次数和点击次数.我们尝试将每个活动与广告系列相关联,以便我们可以报告特定于广告系列的活动.它不起作用.已创建事件,但它们与广告系列无关.

使用analyitcs.js(https://developers.google.com/analytics/devguides/collection/analyticsjs/events#implementation)的事件文档似乎建议我们可以使用字段引用向事件添加其他属性:https:/ /developers.google.com/analytics/devguides/collection/analyticsjs/field-reference

我们的活动创建代码如下:

   $('#campaignImage').on('click', function() {
     ga('send', {
      'hitType': 'event',
      'eventCategory': 'Promotions',
      'eventAction': 'Click',
      'eventLabel': 'IMAGE_TITLE',
      'page': window.location.pathname,
      'campaignName': 'CAMPAIGN_NAME'
     });
   });
Run Code Online (Sandbox Code Playgroud)

事件已成功创建,但未与指定的广告系列相关联(它们都显示为"未设置"广告系列).是否有可能做我们正在尝试做的事情,或者是否只能使用URL参数跟踪广告系列的流量获取?

更新 - 解决方案如下

根据Blexy的推荐

我们切换到使用此处描述的高级电子商务...设置

我们的代码简化:

$( document ).ready(function() {

  //Promotion clicks
  $('.promo-img').on('click', function() {
    ga('ec:addPromo', {              
        'id': $(this).attr('data-campaign'),
        'name': $(this).attr('data-campaign'),
        'creative': $(this).attr('data-unitname'),
        'position': $(this).attr('data-position')
    });
    ga('ec:setAction', 'promo_click');    
    ga('send', {
        'hitType': 'event',
        'eventCategory': 'Internal Promotions',
        'eventAction': 'Click',
        'eventLabel': $(this).attr('data-unitname'),
        'pageview': window.location.pathname
    });
  });

});

$(window).load(function(){

  //Promotion impressions
  if ($('.promo-img').length …
Run Code Online (Sandbox Code Playgroud)

google-analytics

2
推荐指数
1
解决办法
585
查看次数