Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 83
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: autofill login credentials in webview

Thanks alot man....actually i was trying it with "document.getElementById('signIn').submit()"....so it was not working...

 

Neways thanks again...Smiley Happy

Developer
Posts: 83
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: autofill login credentials in webview

But theres some problem with the above code....because whenever i signout  and go back to login page again...the onloading will be called once again...so the account gets logged in again....Hence im unable to signout from my gmail account....

Developer
Posts: 21
Registered: ‎02-13-2014
My Device: Z10 STL-003
My Carrier: AT&T

Re: autofill login credentials in webview

Thats where things get tricky, the script runs whenever the title is 'Gmail' you will need to setup stricter filters. Ie. Use a specific url or have a list of urls visited and execute the script only when the previous and current urls match. This is going to be the most tricky part, executing the script when you need it.
Developer
Posts: 83
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: autofill login credentials in webview

ohh then theres a problem...because im using multiple mail url's like gmail,yahoo,rediff etc...

and im just searching the word google/yahoo/rediff in my url string and accordingly changing the script....

Developer
Posts: 21
Registered: ‎02-13-2014
My Device: Z10 STL-003
My Carrier: AT&T

Re: autofill login credentials in webview

That's fine, just make sure you adjust the if statement to only trigger when you want it to.
Developer
Posts: 21
Registered: ‎02-13-2014
My Device: Z10 STL-003
My Carrier: AT&T

Re: autofill login credentials in webview

Another thing you could try would be to set a variable that acts as a counter. So you would need to set a variable saying it's okay to login, check the variable to see if it's okay to login, then execute your login script and change the variable to 'not okay '. Just decide a good time to reset the variable.
Developer
Posts: 83
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: autofill login credentials in webview

hello,

Can you provide me with the javascript code in the similar way that will set value to those input fields whose type is "email"....This will solve our generalized autofill issue....

I have tried it using below code....but its not working

 

var Email = app.getUsername()
var Passwd = app.getPassword()
var inject = "var inputs = document.querySelectorAll('input[type=email]')"+
"for(var i = inputs.length >>> 0; i--Smiley Wink"+
"{"+
"inputs[i].value = \"" + Email + "\";"+
"}";
webView.evaluateJavaScript(inject);

 

 Please correct me if im doing anything wrong....

 

 

Thanks & Regards

Highlighted
Developer
Posts: 21
Registered: ‎02-13-2014
My Device: Z10 STL-003
My Carrier: AT&T

Re: autofill login credentials in webview

Yeah sure thing.

var inject = "var inputs = document.getElementsByTagName('input');"+
"for(var i = 0; i < inputs.length; i++) {"+
    "if(inputs[i].type.toLowerCase() == 'email') {"+
        "inputs[i].value='"+Email+"';"+
    "}"+
"}";

 Keep in mind that some sites won't specify 'email' as the input type but will use 'text' instead.

Developer
Posts: 21
Registered: ‎02-13-2014
My Device: Z10 STL-003
My Carrier: AT&T

Re: autofill login credentials in webview

Yeah sure thing.

var inject = "var inputs = document.getElementsByTagName('input');"+
"for(var i = 0; i < inputs.length; i++) {"+
    "if(inputs[i].type.toLowerCase() == 'email') {"+
        "inputs[i].value='"+Email+"';"+
    "}"+
"}";

http://stackoverflow.com/questions/5897122/accessing-elements-by-type-on-javascript

 

 Keep in mind that some sites won't specify 'email' as the input type but will use 'text' instead.

Developer
Posts: 83
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: autofill login credentials in webview

Thanks alot man....It worked great...Smiley Happy

i was just missing the "toLowerCase()" in inputs[i].type.toLowerCase()....

Neways thanks again for the quick reply....Smiley Happy Smiley Happy