I'm testing for text input fields that have issues with various characters, and I have no idea where to start, but I want a bookmarklet that fills every form on the page with
¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜–—‘’‚“”„†‡‰‹›€
can anyone help?
Bookmarklet using querySelectorAll
for modern browsers (replace 'my_test_string' with the (optionally escaped) teststring you require):
javascript:(function(s){for(var n=document.querySelectorAll('input[type=text]'), L=n.length; L--; n[L].value=s);})('my_test_string');
Note that you can pass in multiple CSS selectors:
javascript:(function(s){for(var n=document.querySelectorAll('input[type=text], input[type=hidden], textarea'), L=n.length; L--; n[L].value=s);})('my_test_string');
Alternative fallback for legacy browsers (using getElementsByTagName
in conjunction with a short-circuit type test for 'text'):
javascript:(function(s){for(var n=document.getElementsByTagName('input'), L=n.length; L--; n[L].type.toLowerCase()==='text' && (n[L].value=s));})('my_test_string');
Pure javascript, no libraries required!
Hope this gets you started!
PS: Yes, it's 'golfed': it's a bookmarklet (and we need to leave as much room as possible for the (optionally escaped) test-string).. besides the routine is as basic as it can get.. note that the semicolon closing the packed for-loop is required !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.