Log in to site with webview

btbb

Member
Licensed User
Longtime User
Hi,

As i can't solve some issues with httputils2 i'm trying to do it with webview, but with webview i can't even login to the site.

when i use document.forms.loggain.submit() in the javascript the page just updates itself. Why is this happening?

When i remove "document.forms.loggain.submit();" from the code it fills the user textbox on page with username and password box with password and i can login just pushing the button on page.

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

    
   Dim w1 As WebView
   Dim on As Int

      
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Layout1")

   w1.Initialize ("w1")
   
   
   
   Activity.AddView (w1,0,0,100%x,100%y)
      
   
   w1.LoadUrl ("http://www.usabil.nu/message/loggain.asp")
   
   
   

   
   on = 0
End Sub
   

Sub w1_PageFinished (Url As String)


   If on = 0 Then
   
      on =1
   
   
    Dim Javascript As String
     Dim MyWebViewExtras As WebViewExtras    '    you could make this a global variable if you use it elsewhere in your code
     Javascript="document.forms.loggain.txtUsrName.value='User';document.forms.loggain.txtUsrPassword.value='Password';document.forms.loggain.submit();"
   
     MyWebViewExtras.executeJavascript(w1, Javascript)
      
      
      
      
      
   End If
   
   
End Sub

edit: removed b.initialize
 
Last edited:

lagore

Active Member
Licensed User
Longtime User
Why could you not get httputils2 to work, you should be able to login on to a site with it and not have to use a webview. I have done this for quite a few sites.

Sent from my Nexus 7 using Tapatalk 2
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Why could you not get httputils2 to work, you should be able to login on to a site with it and not have to use a webview. I have done this for quite a few sites.

Sent from my Nexus 7 using Tapatalk 2

Could you please give us a simple example ?
 
Upvote 0

btbb

Member
Licensed User
Longtime User
Why could you not get httputils2 to work, you should be able to login on to a site with it and not have to use a webview. I have done this for quite a few sites.

Sent from my Nexus 7 using Tapatalk 2

I have no problem logging in with httputils2, but later when logged in i have to fill a multipart form, and i fail with httputils, so i want to do it with webview instead.
 
Upvote 0
Top