繁体   English   中英

我希望我的程序能够检测到用户何时通过uiwebview(iphone)单击网站上的“提交”按钮

[英]I want my program to detect when the user clicks submit button on a website via uiwebview (iphone)

我想检测用户何时通过uiwebview在网站上单击提交按钮(输入用户名和密码后)。 我需要检测此操作,以便在提交用户信息后立即从登录版本的网页中检索Cookie。

我认为这种检测方法涉及为Webview设置委托,并通过Objective-C编写一些javascript操作。 我不确定。

您将如何解决这个问题? 任何帮助深表感谢!

这是网页代码的一部分:

<form id="login-email" class="badge-login-form" action="https://9gag.com/login" method="POST">
    <input type="hidden" id="jsid-login-form-csrftoken" name="csrftoken" value="999d68db0f5ed15d8966b66f23a52c3b"/>
    <input type="hidden" id="jsid-login-form-next-url" name="next" value=""/>
                            <input type="hidden" name="location" value="1"/>
                    <p class="lead">Log in with your email address </p>
    <div class="field">
        <label for="jsid-login-email-name">Email</label>
        <input id="jsid-login-email-name" type="text" name="username" value="" autofocus="autofocus"/>
    </div>
    <div class="field">
        <label for="login-email-password">Password</label>
        <input id="login-email-password" type="password" name="password" value="" />
                </div>
    <div class="btn-container">
        <input type="submit" value="Log in" onclick="GAG.GA.track('login-signup', 'login', 'login-form');"/>

如果将自己设置为UIWebView的委托,则可以实现以下方法:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSURL *url = request.URL;
    // this is the url you are about to load

    return YES;
}

如果对每组输入使用单独的表单,则可以使用“ onsubmit =”

<form onsubmit="your_function_here "id="login-email" ... >

如果用户单击“提交”或按Enter,则将调用your_function

只是一个想法,希望对您有所帮助

暂无
暂无

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

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