Use Chrome to manually "automatically fill the form"

Source: Internet
Author: User

Address: http://blog.csdn.net/ffb/article/details/38559655

Currently, browsers have the function of automatically filling in forms, which greatly saves us some common forms, especially the time for entering login forms.

However, with the development of user requirements, many web pages use JavaScript to submit forms in real time. These operations may not involve actual submit operations at all, so it will not be intercepted and recorded by the browser. At this time, it will be very depressing to face some common forms that need to be repeated.

However, in this case, you can still manually "automatically fill the form" by using the console function of chrome. You can press F12 on the page to enter the form and click console.


In this test, the form can be automatically filled in at least two ways:

Assume that five input boxes are required: name, address, port, user name, and password.


Method 1:

If these input boxes have IDs, paste the following code in the console and press Enter:

void((function(){document.getElementById("name").value = "localpc";document.getElementById("host").value = "127.0.0.1";document.getElementById("port").value = "22";document.getElementById("username").value = "root";document.getElementById("password").value = "root";// document.getElementById("login").click();})())

The value can be modified according to the actual situation.


Method 2:

If these input boxes only have name and no ID, the following method can automatically fill in the Form (the same is to paste it to the console and press Enter ):

$('[name=name]').val('localpc');$('[name=host]').val('127.0.0.1');$('[name=port]').val('22');$('[name=username]').val('root');$('[name=password]').val('root');

After actual tests, although it is not as good as the automatic completion of the browser, the efficiency is improved a lot. More importantly, it is very practical to enter common forms without occasional mistakes.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.