Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

While on some websites, iPad Safari automatically asks to save form data like Us/Pwd, on other pages, it never asks for the same.

How can we force it to ask for form data save on any website?

share|improve this question
add comment

1 Answer

Add the following bookmarklet to safari:

javascript:(function()%7Bvar%20ca,cea,cs,df,dfe,i,j,x,y;function%20n(i,what)%7Breturn%20i+%22%20%22+what+((i==1)?%22%22:%22s%22)%7Dca=cea=cs=0;df=document.forms;for(i=0;i%3Cdf.length;++i)%7Bx=df%5Bi%5D;dfe=x.elements;if(x.onsubmit)%7Bx.onsubmit=%22%22;++cs;%7Dif(x.attributes%5B%22autocomplete%22%5D)%7Bx.attributes%5B%22autocomplete%22%5D.value=%22on%22;++ca;%7Dfor(j=0;j%3Cdfe.length;++j)%7By=dfe%5Bj%5D;if(y.attributes%5B%22autocomplete%22%5D)%7By.attributes%5B%22autocomplete%22%5D.value=%22on%22;++cea;%7D%7D%7Dalert(%22Removed%20autocomplete=off%20from%20%22+n(ca,%22form%22)+%22%20and%20from%20%22+n(cea,%22form%20element%22)+%22,%20and%20removed%20onsubmit%20from%20%22+n(cs,%22form%22)+%22.%20After%20you%20type%20your%20password%20and%20submit%20the%20form,%20the%20browser%20will%20offer%20to%20remember%20your%20password.%22)%7D)();

You will need to know how to manipulate an existing bookmark to paste this small program in the place a bookmark normally has the URL. This is exactly how programs like Instapaper and Pocket and others use a bookmarklet (which is really a program stored as a bookmark) to change or act on the page you are currently browsing.

Since you should always be a little suspicious when someone posts a program for you to run - here is a clearer version that shows we just loop over all the elements and blindly turn on autocomplete for each.

This makes up for web developers that forgot or intentionally did not enable autocomplete.


Same script as above, but nicely formatted and without the bookmarklet wrapper:

function () { var ca, cea, cs, df, dfe, i, j, x, y;

function n(i, what) {
    return i " "
    what((i == 1) ? "" : "s")
}
ca = cea = cs = 0;
df = document.forms;
for (i = 0; i < df.length; i) {
    x = df[i];
    dfe = x.elements;
    if (x.onsubmit) {
        x.onsubmit = "";
        cs;
    }
    if (x.attributes["autocomplete"]) {
        x.attributes["autocomplete"].value = "on";
        ca;
    }
    for (j = 0; j < dfe.length; j) {
        y = dfe[j];
        if (y.attributes["autocomplete"]) {
            y.attributes["autocomplete"].value = "on";
            cea;
        }
    }
}
alert("Removed autocomplete=off from "
n(ca, "form")" and from "
n(cea, "form element")", and removed onsubmit from "
n(cs, "form")". After you type your password and submit the form, the browser will offer to remember your password.")

}

share|improve this answer
2  
Can you add some explanation concerning what the purpose of the bookmarklet is anyhow it works? This would help in reducing concerns of potential users to load a bookmarklet from a more or less anonymous source. –  patrix Nov 8 '11 at 15:45
    
yes sure...i would also like to understand how to use this... –  hmthr Nov 11 '11 at 9:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.